#################################################################### # This is a test of WWW::Mechanize::Chrome #################################################################### use strict; use warnings; use File::Path; use Log::Log4perl qw(:easy); # used by WWW::Mechanize::Chrome use WWW::Mechanize::Chrome; my $chrome = ""; my $page = ""; Log::Log4perl->easy_init($TRACE); # Set priority of root logger to ERROR # clean up data_directory to start fresh each time. mkdir("/temp/"); rmtree("/temp/mechaChrome/"); mkdir("/temp/mechaChrome/"); $chrome = WWW::Mechanize::Chrome->new( #autoclose => 0, # when script is complete close the browser (default yes) data_directory => '/temp/mechaChrome/', # this fixes the "Do you maybe have a non-debug instance of Chrome already running?" timeout error by forcing a new instance of chrome. start_url => 'https:\\www.cnn.com', launch_arg => [ " --enable-logging", "--v=1" ] ); print("sleeping\n"); sleep(30); print("Load reddit\n"); $page = $chrome->get("https://www.reddit.com/"); print("sleeping\n"); sleep(30); print("Load slashdot\n"); $page = $chrome->get("https://slashdot.org/"); print("sleeping\n"); sleep(30); print("Script done\n"); exit(0);