I'm having a hard time trying to select an element from a dropdown menu with Selenium.
Inspecting the page it looks like this:
<select id="numbers" name="numbers" style="display: inline-block;">
<option value="all">all numbers</option>
<option value="c4ca4238a0b923820dcc509a6f75849b">One</option>
<option value="c81e728d9d4c2f636f067f89cc14862c">Two</option>
<option value="34173cb38f07f89ddbebc2ac9128303f">Three</option>
</select>
The code I'm using is:
element = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="numbers"]/option[3]'))
)
element.click();
But I'm receiving the error:
EC.element_to_be_clickable((By.XPATH, '//*[@id="numbers"]/option[3]'))
File "/Library/Python/2.7/site-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
at FirefoxDriver.prototype.findElementInternal_ (file:///var/folders/7q/ttwklc8j10x_8q7yy8t2scpw0000gn/T/tmpYJKH0R/extensions/[email protected]/components/driver-component.js:10770)
at FirefoxDriver.prototype.findElement (file:///var/folders/7q/ttwklc8j10x_8q7yy8t2scpw0000gn/T/tmpYJKH0R/extensions/[email protected]/components/driver-component.js:10779)
at DelayedCommand.prototype.executeInternal_/h (file:///var/folders/7q/ttwklc8j10x_8q7yy8t2scpw0000gn/T/tmpYJKH0R/extensions/[email protected]/components/command-processor.js:12661)
at DelayedCommand.prototype.executeInternal_ (file:///var/folders/7q/ttwklc8j10x_8q7yy8t2scpw0000gn/T/tmpYJKH0R/extensions/[email protected]/components/command-processor.js:12666)
at DelayedCommand.prototype.execute/< (file:///var/folders/7q/ttwklc8j10x_8q7yy8t2scpw0000gn/T/tmpYJKH0R/extensions/[email protected]/components/command-processor.js:12608)
For what I'm able to understand it's failing to locate the xpath, even if i double-checked copy/pasting it from Chrome.
What am I missing? Thank you for your help.
select#numbers option:nth-child(3)