Reputation: 107
I am running on: windows 7 watir-webdriver 0.6.4 selenium-webdriver (2.35.1, 2.35.0, 2.31.0)
<div>
//more embedded codes...
<div id="emd1" class="ui-select" style="float: left; width: 90%;">
<a id="emb1" class="ui-btn ui-btn-icon-right ui-btn-corner-all ui-shadow ui-btn-up-d" href="#" role="button" aria-haspopup="true" aria-owns="emb1" data-theme="d">
<span class="ui-btn-inner ui-btn-corner-all" aria-hidden="true">
<span class="ui-btn-text">Choose one... </span>
<span class="ui-icon ui-icon-arrow-d ui-icon-shadow"></span>
</span>
</a>
<select id="emu1" data-placeholder="true" data-native-menu="false" serial="1" sequenceid="1" tabindex="-1">
<option value="">Choose one...</option>
<option value="A">Apple </option>
<option value="B">Banana </option>
<option value="C">Cat </option>
<option value="D">Dog </option>
<option value="E">Elephant </option>
<option value="F">Fish </option>
</select>
</div>
</div>
whenever I want to select ddl, I just do this all the time and it always worked fine
browser.select_list(:id = "emu1").select("Apple")
and it will get the job done. Suddenly it stop working. I am not sure if its due to recent upgrade I did on selenium-webdriver, and watir-webdriver. Or due to code change.
browser.a(:id => "emb1").wait_until_present
works fine
browser.select_list(:id => "emu1").wait_until_present
wait for 30 sec and giving me the couldn't find element error.
anyone else having any similar issue? Any help is good. Thanks in advance.
Upvotes: 3
Views: 1156
Reputation: 223
Without seeing the CSS that displays the HTML I cannot be 100% certain, but I have a hunch the user-facing select list is actually a styled <span>
. The <select>
is likely being hidden by CSS. If the <select>
is hidden by CSS, webdriver is unable to 'see' the it.
To expose select lists like this, I've used JavaScript to alter the select
's display
attribute. I've added this snippet to my watir-webdriver toolbox before accessing fancy select_lists
:
script = %q{document.getElementById("emu1").style.display = "block");}
browser.execute_script(script)
This alters the display properties of the select list, so it can now accessed by the all of the select_list
commands available to webdriver.
You can give this a try by heading to the page with the select list and opening the developer console of your preferred web browser. Try the following and see if you now see a select list appear:
document.getElementById("emu1").style.display = "block";
If that doesn't work, try using display = "inline"
. If a standard HTML select list now displays, you've found the culprit and the solution.
Upvotes: 5