Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: WWW::Mechanize::Chrome - how to deal with new windows/tabs

by mscha (Acolyte)
on Sep 06, 2020 at 20:07 UTC ( [id://11121418]=note: print w/replies, xml ) Need Help??


in reply to Re: WWW::Mechanize::Chrome - how to deal with new windows/tabs
in thread WWW::Mechanize::Chrome - how to deal with new windows/tabs

Thanks, your first example does the trick for me! (The second could be useful as well, depending on the use case.)

$mech->get('https://www.mscha.org/knmi/summer.cgi?month=-1'); $mech->follow_link(text=>'2020'); # opens a new window my $chrome = $mech->driver; my @tabs = $chrome->getTargets()->get; my ($new_tab) = grep { $_->{url} =~ m{graph} } @tabs; $chrome->connect(tab=>$new_tab)->get; my $png = $mech->content_as_png;

I don't have control over the site I want to eventually use this for, and it opens new tabs all over the place. So I do need to be able to do this.
It might be useful for other people to include some documentation or an example that shows tab switching.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-03-29 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found