1

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:

SIZECHOOSE=Select(driver.find_element(By.CLASS_NAME,"RYghuO._7Cm1F9.dgII7d.pVrzNP"))
SIZECHOOSE.select_by_visible_text("41")

Snapshot of HTML:

Code of website Zalando

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Do you need every element with the number 41? You can scrap all of them, and then filter... Just an idea – interferemadly Jul 08 '22 at 12:19
  • @interferemadly I need it to pick a random number from the numbers I specify in advance and to filter unavailable and replace with available – Lukáš Čimo Jul 08 '22 at 12:23

1 Answers1

1

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()
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352