#!usr/bin/perl use strict; use warnings; use WWW::Mechanize::Firefox; my $mech = WWW::Mechanize::Firefox->new(autoclose => 0); $mech->allow(javascript => 1); #$mech->get('http://www.acehardware.com/mystore/storeDetail.jsp?store=14671', ':content_file' => 'webpage.txt'); $mech->get('http://www.acehardware.com/mystore/storeDetail.jsp?store=14671'); my $retries = 10; while ($retries-- and ! $mech->is_visible( xpath => '//*[@id="city"]' )) { sleep 1; }; die "Timeout" unless $retries; # Now the element exists #$mech->click({xpath => '//*[@id="submit"]'}); print "..." . $mech->xpath('//dataAddress2[id="city"]', one => 1); open(FO,">test.txt") or die "unable"; print FO $mech->content; print "DONE!";