sub wait_until_xpath(){ eval{ my $xpath=shift; my $retries = 90; while ($retries-- and ! $mech->is_visible( xpath => $xpath )) { print "wax waited..\n"; usleep(50*$msec); }; warn "wait_until_xpath(): timeout at retry #$retries" if 0 > $retries; } }