Selenium: Select by number within span element


All avaible sizes had same class but I need to select by numbers in span.
I tried by doing this, but select function dont work with span element.

Code trials:


Snapshot of HTML:

Code of website Zalando


As the element is not a element so you won’t be able to use the Select() class.

To click on a any specific number you can use either of the following Locator Strategies:

  • Using xpath and normalize-space():

    driver.find_element(By.XPATH, "//span[normalize-space()='42']").click()
  • Using xpath and contains():

    driver.find_element(By.XPATH, "//span[contains(., '42')]").click()

Answered By – undetected Selenium

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published