-1

I want to click on the following button:

https://i.stack.imgur.com/ifiDC.png

So far my code looks like this, but nothing happens:

https://i.stack.imgur.com/Cgi5v.png

Thank you for your help :)

  • can you print the value of find_element_by_css_selector ? – yadavankit Jun 15 '19 at 10:55
  • 1
    Please avoid to post snapshot.These are more confusing to OP to provide you solutions.Post html in text format and as well code. – KunduK Jun 15 '19 at 12:17
  • Please read why a [screenshot of HTML or code or error is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Consider updating the Question with formatted text based relevant HTML, code trials and error stack trace. – undetected Selenium Jun 15 '19 at 12:52

2 Answers2

1

You Can Do the following:

  1. Using @class='fl-product-size--item fl-product-size--item__not-available you can create a unique locator.
  2. If Only @class do not provide you unique locator you can take help from Parent-Child RelationShip or Sibling Node.
  3. Creating Unique locator is the main thing.Hope this helps you.
Asif Rouf
  • 166
  • 2
  • 7
0

You need to use xpath as CSS locator have three elements for the same.

I checked the xpath in website, as 48 size is not available ,but xpath is like that

//button[@class='fl-product-size--item fl-product-size--item__not-available']//span[text()='48']
iamsankalp89
  • 4,607
  • 2
  • 15
  • 36
  • This is what my code looks like now. Still doesn't work :/. from selenium import webdriver browser = webdriver.Chrome('/Users/main/Downloads/chromedriver') browser.get('https://www.footlocker.de/de/p/adidas-am4-thanos-herren-schuhe-80563?v=314205818504#!searchCategory=herren/schuhe/running') elem = browser.find_element_by_xpath('//button[@class="fl-product-size--item"]//span[text()="48"]').click() –  Jun 16 '19 at 09:33