Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: help clicking radio buttons using WWW::Mechanize::Chrome

by Corion (Patriarch)
on Jan 13, 2021 at 20:01 UTC ( [id://11126865]=note: print w/replies, xml ) Need Help??


in reply to Re^2: help clicking radio buttons using WWW::Mechanize::Chrome
in thread help clicking radio buttons using WWW::Mechanize::Chrome

Ouch - yes, that is an inconsistency/bug in the behaviour of ->click(). When the ->click() method results in external HTTP requests, then the returned value is an HTTP::Response object. When the result is just some internal Javascript code, the result is an arrayref of the triggered events. This is wrong and I'll make it so that ->click always returns an HTTP::Response object, as documented.

Replies are listed 'Best First'.
Re^4: help clicking radio buttons using WWW::Mechanize::Chrome
by Special_K (Monk) on Jan 15, 2021 at 18:30 UTC

    I noticed that adding the following line from your example fixed my code:

    $mech->sleep(5);

    Generally speaking, should one always call $mech->sleep(); after a call to $mech->get() (and possibly other methods)? I didn't see this explicitly mentioned in the documentation for the get() method but I'm not a web developer so maybe it's just common knowledge that something like that is required?

      This depends on the page. In theory it should not be necessary, but if the page loads other Javascript scripts and more content before it "really" displays the content, this cannot be detected by WWW::Mechanize::Chrome. In such cases, you need to blindly call ->sleep() and hope that the content arrives in time.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11126865]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 06:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found