1

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?

5
  • 1
    You have display "none" in the style definition Commented May 5, 2016 at 12:20
  • style="width: 250px; display: none;" Commented May 5, 2016 at 12:33
  • So I cannot select anything because it's not displayed? Commented May 5, 2016 at 12:34
  • That exactly what selenium saying: "the element not visible" Commented May 5, 2016 at 12:35
  • Ok, thanks. Now, it comes to my mind, when I inspect the dropdown menu, it doesn't redirect me to the select contruction, but to this: <span class="combo" style="width: 248px;"> <input type="text" class="combo-text validatebox-text" autocomplete="off" readonly="readonly" style="width: 230px;"> <span> <span class="combo-arrow"> </span> </span> <input type="hidden" class="combo-value" name="formIdVeic" value="TN"> </span>. What can I do with this? Commented May 5, 2016 at 12:37

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.