开发者

Selenium - Clicking on image which has random id

开发者 https://www.devze.com 2023-02-02 08:36 出处:网络
Below is the code, and the imd id is randomly generated. i want to click on the image to remove a data in the grid. but note, this image is present in more grids. so if i give src it is removing the f

Below is the code, and the imd id is randomly generated. i want to click on the image to remove a data in the grid. but note, this image is present in more grids. so if i give src it is removing the first data and not the required data which i want.

img id="img30" onclick="removeTest("30A0");" onmouseout="hideImage('img30')" src="resources/images/button开发者_JAVA技巧_delete.gif" style="visibility: hidden;"/>


You can navigate beackwards in xPath-expressions using "/../" so you may just locate your data-row and then move up, an click the image

like this

click //div[@id="yourDataGrid"]//tr//td[contains(text(),"whateverdataYouWantToDelete")]/..//img
0

精彩评论

暂无评论...
验证码 换一张
取 消