如果有人需要参考或背景,这是我问的第一个问题
检索 WebElements 列表并识别它们 https://stackoverflow.com/questions/36186674/retrieving-a-list-of-webelements-and-identifying-them/36305024#36305024
此时我已经检索到了 WebElements 列表
@FindBy(css = "td[id^=ctl00_SomeGridData_ucControlList_trgControlList_ctl00__]")
List<WebElement> allGridData;
此时,在我的代码中,我可以使用 web 元素来调用索引
allGridData.get(0).click
但是该列表并不是严格的整数,例如如果我在行级别访问<tr>
这将是:
ctl00_SomeGridData_ucControlList_trgControlList_ctl00__0
但如果我要调用行内的链接,它们就是表数据<td>
分成如下的 div:
ctl00_SomeGridData_ucControlList_trgControlList_ctl00__ctl04_lbView
ctl00_SomeGridData_ucControlList_trgControlList_ctl00__ctl04_hlTestPlan
or this
ctl00_SomeGridData_ucControlList_trgControlList_ctl00__ctl07_lbView
ctl00_SomeGridData_ucControlList_trgControlList_ctl00__ctl07_hlTestPlan
由于所有 WebElements 都以通用的 css 选择器开始
@FindBy(css = "td[id^=ctl00_SomeGridData_ucControlList_trgControlList_ctl00__]")
List<WebElement> allGridData;
如何识别作为 char 值(即 ctl107)的特定索引与只是一个整数?