Reputation: 167
Trying to convert the below given HTML
tag of a Image Button
which I want to click but not getting clicked while using Xpath
.
HTML Script
<img src="../../../../imagepool/transparent%21tmlservicedesk?cid=1"
id="reg_img_304316340" aralttxt="1" artxt="Show Application List"
arimgcenter="1" alt="Show Application List" title="Show Application List"
class="btnimg" style="top:0px; left:0px; width:23px; height:140px;">
Xpath Generated for the same:
//div[@class='btnimgdiv']/img[@id='reg_img_304316340']/@src
Read some of the articles that for image buttons CSS selector is much better than xpath and wanted to know how to convert the html to CSS selector.
Upvotes: 4
Views: 2528
Reputation: 23805
Image BUtton which i want to click but not getting clicked while using Xpath
This is because you are using id
attribute value of the element which looks like dynamically generated.
Read some of the articles that for image buttons CSS selector is much better than xpath
Yes, you are right, using cssSeector
is much faster than xpath
to locate an element.
wanted to know how to convert the html to CSS selector.
You need to use that attribute value which is unique and unchangeable to locate element, you can use below cssSelector
:-
img.btnimg[title='Show Application List']
Reference Link :-
Upvotes: 2