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.
In reply to Re^2: WWW::Mechanize::Chrome - how to deal with new windows/tabs
by mscha
in thread WWW::Mechanize::Chrome - how to deal with new windows/tabs
by mscha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |