5

How do I click the size button and add to cart using selenium web driver and python?

This is for the website below

http://store.nike.com/us/en_us/pd/dri-fit-cool-tailwind-stripe-running-shirt/pid-10739300/pgid-11072108

Please let me know if there is anything I should paste in here related to the size button.

1
  • Sorry I am actually using webdriver plus the firefox selenium IDE plugin.
    – david
    CommentedMay 2, 2016 at 16:24

1 Answer 1

8

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()") 
2
  • 1
    I am experimenting with this example code, but I think I am using the incorrect class name because I'm getting "WebDriverException: Message: Element is not clickable at point " What class name should I be using?
    – david
    CommentedMay 2, 2016 at 16:36
  • 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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.