Skip to content
Advertisement

Why am I unable to select an item in a dropdown?

I have the following MRE code that is mean to select EU Odds from a dropdown:

from pathlib import Path
from time import sleep

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait

chrome_driver = str(Path("chromedriver/chromedriver/"))
driver = webdriver.Chrome(chrome_driver)
driver.get("https://www.oddsportal.com/matches/tennis/")
driver.find_element(By.ID, "user-header-oddsformat-expander").click()
sleep(1)
wait = WebDriverWait(driver, 10)
target = "EU Odds"
wait.until(ec.element_to_be_clickable((By.XPATH, "//li[.='" + target + "']"))).click()

Everything works up until the final line which doesn’t make the selection. If I try to do this manually on the page that chromedriver opens then I’m also unable to make the selection. However, if I open up a normal browsing window then I am able to make the selection.

Where am I going wrong?

Advertisement

Answer

The actual issue is with the website itself. Trying to select any other option other than EU Odds doesn’t work even manually. Seems like you need to be logged in to do that.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement