Reputation: 480
In the code:
<img style="cursor: pointer; background-color: transparent;" onclick="changeTeamHint(2155);" src="/images/icon_edit_inactive.png">
onclick="changeTeamHint(2155);"
is always changing. The number increases as I add more fields to my form.
How do I get the last element in Selenium IDE? For example, if I add a text field with "changeTeamHint(2156)"
, how do I use Selenium IDE to select the latest one? If its 2157, it selects 2157. Etc.
Here's what I got so far: xpath=(//img[@style='cursor:pointer;'])[last()]
But my coworker told me to try to find it by onclick, and here's what I got that works: xpath=(//img[@onclick='changeTeamHint(2155);'])[last()]
I tried: xpath=(//img[@onclick='changeTeamHint();'])[last()]
, but it gives me an error
Upvotes: 4
Views: 5534
Reputation: 46836
I think you want to do a starts-with for value of the onclick attribute:
xpath=(//img[starts-with(@onclick, 'changeTeamHint')])[last()]
Upvotes: 7