How to get selenium to click on an object other than by ID
Posted
by Zombies
on Stack Overflow
See other posts from Stack Overflow
or by Zombies
Published on 2010-05-14T19:41:48Z
Indexed on
2010/05/14
19:44 UTC
Read the original article
Hit count: 220
So here is a little challenge. I have an image. It has 2 attributes:
- a random ID - not helpful
- an image url - but it is a button, and other buttons use the same image url, not helpful
- a CSS class - also used by too many other things to be helpful
- a style - neither helpful nor unique
This image is however inside of an anchor tag, but the anchor tab isn't to a page, it just runs some javascript. Bellow is the html in question:
<a id="template:j_id__ctru168pc2"
title="Click for the Manual Class LOV" class="xei" style="text-decoration: none;"
onclick="return false;" href="#">
<img id="template:j_id__ctru169pc2" class="xgs"
style="border: 0pt none;" src="images/lov_ena.png">
</a>
How can I click this image without using the ID?
© Stack Overflow or respective owner