How do I click the size button and add to cart using selenium web driver and python?
This is for the website below
Please let me know if there is anything I should paste in here related to the size button.
How do I click the size button and add to cart using selenium web driver and python?
This is for the website below
Please let me know if there is anything I should paste in here related to the size button.
A python example:
driver = webdriver.Firefox() driver.get("http://store.nike.com/us/en_us/pd/dri-fit-cool-tailwind-stripe-running-shirt/pid-10739300/pgid-11072108") driver.execute_script("document.getElementsByClassName('theClassName')[0].click()")
Please note that ('theClassName')[0]
will match the first element with theClassName
, you may need to increase the number.
To get the element by its ID, use:
driver = webdriver.Firefox() driver.get("http://store.nike.com/us/en_us/pd/dri-fit-cool-tailwind-stripe-running-shirt/pid-10739300/pgid-11072108") driver.execute_script("document.getElementById('theIdName').click()")
store.nike.com
may have changed their code and you'll have to take a look at the source code.CommentedMay 12, 2022 at 22:25