Here's the HTML of what looks to be a dropdown list:
<div id="Form-PlaceList-boundlist" class="x-boundlist x-boundlist
floating x-layer x-boundlist-default x-border-box x-boundlist-above">
<div id="Form-PlaceList-boundlist-listEl" class="x-boundlist-list-ct
x-unselectable" role="presentation">
<ul class="x-list-plain">
<li class="x-boundlist-item x-boundlist-item-over x-boundlist-selected"
role="option" unselectable="on"></li>
<li class="x-boundlist-item" role="option" unselectable="on">Alabama</li>
<li class="x-boundlist-item" role="option" unselectable="on">Alaska</li>
<li class="x-boundlist-item" role="option" unselectable="on">Atlantis</li>
Using Selenium with Python 2.7, I've trying to select one of the list/option elements. I can get the desired element by using
driver.find_element_by_xpath("//div[@id='Form-PlaceList-boundlist-ListEl']/ul/li[62]")
...except the list order changes from time to time, and row number #62 isn't sometimes the right element.
Can you select this element based on "Wyoming" rather than the index number?
I also tried getting it with sending a Javascript command to the Selenium driver with driver.execute_script. I tried:
driver.execute_script("document.getElementByID('Form-PlaceList-boundlist-listEl').setAttribute('value','Wyoming')")
but this gives Cannot read property 'setAttribute' of null.