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. Commented May 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()")
Sign up to request clarification or add additional context in comments.

2 Comments

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?
store.nike.com may have changed their code and you'll have to take a look at the source code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.