use WWW::Mechanize::Firefox; ... my @buttons = $mech->xpath('//input[@value="Add To Cart"]'); #this find 6 buttons on the page foreach my $button (@buttons){ $mech->click_button(input=>$button); #this hangs }