如何在Selenium IDE中获取总是在变化的最后一个元素

yan*_*yan 3 selenium xpath

在代码中:

<img style="cursor: pointer; background-color: transparent;" onclick="changeTeamHint(2155);" src="/images/icon_edit_inactive.png">
Run Code Online (Sandbox Code Playgroud)

onclick="changeTeamHint(2155);"总是在变化.当我向表单添加更多字段时,数字会增加.

如何获取Selenium IDE中的最后一个元素?例如,如果我添加一个文本字段"changeTeamHint(2156)",如何使用Selenium IDE选择最新的?如果它是2157,它选择2157.等等.

这是我到目前为止所得到的: xpath=(//img[@style='cursor:pointer;'])[last()]

但我的同事告诉我试图通过onclick找到它,这就是我得到的有效: xpath=(//img[@onclick='changeTeamHint(2155);'])[last()]

我试过:xpath=(//img[@onclick='changeTeamHint();'])[last()]但它给了我一个错误

Jus*_* Ko 6

我想你想为onclick属性的值做一个start-with:

xpath=(//img[starts-with(@onclick, 'changeTeamHint')])[last()]
Run Code Online (Sandbox Code Playgroud)