如果有人需要參考或背景這裏是我的第一個問題問WebElement名單召喚單項指標
Retrieving a list of WebElements and Identifying them
此時我已取回
@FindBy(css = "td[id^=ctl00_SomeGridData_ucControlList_trgControlList_ctl00__]")
List<WebElement> allGridData;
WebElements列表此時在我的代碼中,我可以使用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
或本
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)vs只是一個整數?
您可以發佈您正在使用的HTML代碼嗎?將事情弄清楚。 – alecxe
已在頂部更新 –