<ul id="sbdd769163470" class="selectbox items w254 black loginregister-salute-js-selector above" role="menu" aria-hidden="true" style="max-height: 1158.3px; position: absolute; visibility: visibl…; width: 284px; display: none; left: 317.5px; top: 1068.3px;">
<li id="sbo921604109" class="selected first" role="option" aria-disabled="">
<div class="item">
<div class="text">
FooTextOne
</div>
</div>
</li>
<li id="sbo94742309" role="option" aria-disabled="">
<div class="item">
<div class="text">
FooTextTwo
</div>
</div>
</li>
<li id="sbo371109326" role="option" aria-disabled="">
<div class="item">
<div class="text">
FooText3
</div>
</div>
</li>
<li id="sbo295046620" role="option" aria-disabled="">
<div class="item">
<div class="text">
FooText4
</div>
</div>
</li>
<li id="sbo768447951" class="last" role="option" aria-disabled="">
<div class="item">
<div class="text">
FooText5
</div>
</div>
</li>
</ul>
</div>
<select id="sel_salut" class="w254 black loginregister-salute-js-selector has_sb" name="salutation" style="display: block;">
<option value="FooText1"></option>
<option value="FooText2"></option>
<option value="FooText3"></option>
<option value="FooText4"></option>
<option value="FooText5"></option>
</select>
Okay so this is the websites code. I literally have no clue why that weird ... structure. I guess it's related to some CMS.
The thing is: I address the "select" by doing:
driver.findElement(By.id("sel_salut"));
As you can see there is only one element on the page that matches this search: The select box.
Alright, now i do:
Select select = new Select(whatIJustFound);
select.selectByValue("fooTextOne");
Works, perfectly fine. Now, consider
select.selectByValue("fooBarTwo");
Error: Element is not visisble and bla bla may not be interacted with.
It became obvious that selinium somehow references the above values here. From the ul thing. As you can see the first value "FooTextOne" is visible while all others are disabled.
YET i have already printed the WebElement that i wrap Select = new () around. It IS the select expected. I have outputted the classname and it is EXACTLY what the select element has.
I also already simulated a click onto the Dropdown, incase it is somehow forbidden to select from it if it has not previously been clicked on. Same result: Doesnt work for anything other than the default (FoobarOne)-text.
I dont understand what is going on.
One more note: It works perefectly fine using ChromeDriver(). It doesn't using FirefoxDriver() like i do currently.
Aucun commentaire:
Enregistrer un commentaire