我正在尝试webelements
从AJAX
下拉菜单中收集列表以进行迭代以验证每个项目的值。
我这样做的方式是通过以下代码:
List<WebElement> names = new ArrayList<WebElement>();
names = pgNew.driver.findElements(By.className("col1"));
但是,当我运行它时,names
只接收前两项className col1
而不是全部 15。相反,它将最后 13 个点存储为空白。例如,如果它应该接受:
a、b、c、d、e、f、g、h、i、j、k、l、m、n、o
它只接受:
a,b,'','','','','','','','','','','','',''
有任何想法吗?
编辑:
这是html代码:
<div class="iceSelInpTxt patientAutoComplete">
<input id="mainForm:TextBox">
<div id="mainForm:TextBox_div">
<div>
<div class="iceSelInpTxtSelRow AutoCompleteSelRow">
<span class="informal">
<table class="table" width="100%">
<tbody>
<tr style="cursor: pointer;">
<td class="col1">Text</td>
<td class="col3">Text</td>
<td class="col1">Text</td>
</tr>
</tbody>
</table>
</span>
<span style="visibility:hidden;display:none;">MRN5218317218</span>
</div>
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
<div class="iceSelInpTxtRow pAutoCompleteSelRow">
</div>
</div>
<input type="hidden" name="mainForm:TextBox_idx" style="" value="">
</div>
以下“iceSelInpTxtRow pAutoCompleteSelRow”都是相同的,“col1”、“col3”和“col1”的值不同。
另外,请注意,此问题仅在 FireFox 中发生。