我有两个相似的动态下拉列表,我无法从第二个下拉列表中进行选择。下面是html:
<div id="list" class="x-list">
<div id="list-list" class="x-list-list-ct">
<ul>
<li class="x-item" role="option">US Dollar - USD</li>
<li class="x-item x-list-selected x-list-item-over" role="option">Afghan Afghani - AFN</li> //<--this is my 1st selection from 1st dropdown list
<li class="x-item" role="option">Albanian Lek - ALL</li>
<li class="x-item" role="option">Algerian Dinar - DZD</li>
<li class="x-item" role="option">Angolan Kwanza - AOA</li>
<li class="x-item" role="option">Argentine Peso - ARS</li>
</ul>
</div>
</div>
<div id="list" class="x-list">
<div id="list-list" class="x-list-list-ct">
<ul>
<li class="x-item x-list-selected x-list-item-over" role="option">US Dollar - USD</li> //<--this is my default hover selection
<li class="x-item" role="option">Afghan Afghani - AFN</li>
<li class="x-item" role="option">Albanian Lek - ALL</li>
<li class="x-item" role="option">Algerian Dinar - DZD</li>
<li class="x-item" role="option">Angolan Kwanza - AOA</li>
<li class="x-item" role="option">Argentine Peso - ARS</li>
</ul>
</div>
</d
当一个元素被选中或悬停时,类名更改为“x-item x-list-selected x-list-item-over”
对于第一个列表,我使用 driver.findElement(By.xpath("//li[text()[contains(.,'Afghan Afghani - AFN')]]")).click();
当我对第二个列表执行相同操作时,元素被选中但列表没有关闭。