Reputation: 1107
I have to select an option from a dropdown menu, the HTML code is
<select id="formIdVeic" style="width: 250px; display: none;" class="combobox-f combo-f" comboname="formIdVeic">
<option value="" selected="selected"></option>
<option value="E">TARGA ESTERA </option>
<option value="J">TARGA FILOBUS </option>
<option value="L">TELAIO </option>
<option value="TN" selected="selected">TARGA ITALIANA NUOVO FORMATO </option>
<option value="TS">TARGA ITALIANA SPECIALE </option>
<option value="TV">TARGA ITALIANA VECCHIO FORMATO </option>
<option value="X">TARGA PROVA </option>
<option value="Y">TARGA PROVVISORIA </option>
</select>
I want to select the "TV" option. The solution I've come to is
from selenium.webdriver.support.select import Select
...
a=Select(browser.find_element_by_xpath('//select[@id="formIdVeic"]'))
a.select_by_visible_text("TARGA ITALIANA VECCHIO FORMATO").click()
or
a.select_by_value("TV").click()
where browser is a web browser driver. Both the solutions return an exception:
ElementNotVisibleException: element not visible:
Element is not currently visible and may not be manipulated
Where am I doing wrong?
Upvotes: 1
Views: 915
Reputation: 1895
You can't select the non visible element in Selenium. The source for the visibility check -
https://github.com/SeleniumHQ/selenium/blob/master/javascript/atoms/dom.js#L577
Upvotes: 1