use strict; use warnings; use WWW::Mechanize::Firefox; my $mech = WWW::Mechanize::Firefox->new( activate => 1, # bring the tab to the foreground ); $mech->get('https://familysearch.org/search/collection/results#count=20&query=%2Bevent_place_level_1%3ACalifornia%20%2Bevent_place_level_2%3A%22San%20Diego%22%20%2Bbirth_year%3A1923-1923~%20%2Bgender%3AM%20%2Brace%3AWhite&collection_id=2000219',':content_file' => 'main.html', synchronize => 0); my $retries = 10; while ($retries-- and $mech->is_visible( xpath => '//*[@id="hourglass"]' )) { print "Sleep until we find the thing\n"; sleep 2; }; die "Timeout while waiting for application" if 0 > $retries; # Now the hourglass is not visible anymore #fill out the search form my @forms = $mech->forms(); # #A selector prefixed with '#' must match the id attribute of the input. A selector prefixed with '.' matches the class attribute. A selector prefixed with '^' or with no prefix matches the name attribute. $mech->field( birth_place => 'value_for_birth_place' ); # Click on the submit $mech->click({xpath => '//*[@class="form-submit"]'});