Selenium Select option list too long and cannot select item

173 Views Asked by At

On a webpage in I am interacting with Selenium a dropdown seems to be too long and won't load all the options so I cannot select any items. The code works elsewhere with shorter lists but not this one, which contains 500-1000 options. The only select option that even comes close to working is 'select_by_index' but the program hangs when using it.

Is this a known issue? How can I work around this? The internet browser is Internet Explorer.

Generalized version of the HTML. It is a Select with a little over ~400 Options. The Select is within a table on the page:

<SELECT name="aBigSelect" id="aBigSelect" onchange="OptionMenuSubmit(this, this.name)"style="" >
<OPTION value="" selected ></OPTION>
<OPTION value="option1">option1</OPTION>
<!-- About 400+ more options...
<OPTION value="option430">value430</OPTION>
</SELECT>

The Python code:

selectXpath = "//*/select[contains(@name, 'aBigSelect')]"
aBigSelect = Select(driver.find_element_by_xpath(selectXpath))
aBigSelect.select_by_value("value1")

Running this code to select the option causes this error:

selenium.common.exceptions.NoSuchElementException: Message: Cannot locate option with value: value1 
0

There are 0 best solutions below