简体   繁体   中英

How to click on this button on Webpage using Perl and Mechanize

This may sound very simple to expirenced Perl Scripters, but I'm trying to click on a button on a webpage using Perl and the WWW::Mechanize::Firefox from CPAN. Here is the source code for the button:

<button type="submit" class="add-to-cart nsg-button--nike-orange" >

                        ADD TO CART

        </button>

This is not the only button on the page by the way, my current method of trying to click on it is click_button => 'ADD TO CART' but that does not seem to be working for me. Any help on clicking this button is greatly needed . Thank you.

You should be able to call $mech->click({ selector => '.add_to_cart' }); according to the documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM