use strict; use warnings; use Log::Log4perl qw(:easy); use WWW::Mechanize::Chrome; Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ERROR my $mech; my( $chrome, $diagnosis ) = WWW::Mechanize::Chrome->find_executable(); print "error: [$diagnosis]\n" if $diagnosis; print "Should I use ",( $chrome ? "[$chrome]" : "-NOT FOUND-" ), " or another executable (put full path or leave blank for default)\n"; my $chrome_path = ; chomp $chrome_path; $chrome_path = $chrome_path ? $chrome_path : $chrome; print "I have to use an existing chrome tab ( for example PerlMonks )? leave it blank to open a new browser instance\n"; my $tab_title = ; chomp $tab_title; if ( $tab_title ){ $mech = WWW::Mechanize::Chrome->new( autoclose => 0, # has no effect autodie => 0, incognito => 0, # has no effect tab => qr/$tab_title/, ); } else{ print "Give me the full url to connect ( for example https://www.perlmonks.org )\n"; my $url = ; chomp $url; $mech = WWW::Mechanize::Chrome->new( autoclose => 0, # has no effect autodie => 0, incognito => 0, # has no effect launch_exe => $chrome_path, launch_arg => [ "--remote-debugging-port=9222" ] ); $mech->get( $url ); } sleep 5; # go from Monastery Gates to Newest Nodes $mech->click ( { selector => '#titlebar-top tbody tr td.monktitlebar ul li:nth-child(15) a'} ); print "Press ENTER to continue... (if the browser was open by $0 will be closed despite of autoclose => 0)"; my $ready = ;