Amit
Amit

Reputation: 167

Convert to CSS Selector

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.

BMC Remedy site- need to click on the Application Image button, which i am not able to click through Xpath

Upvotes: 4

Views: 2528

Answers (1)

Saurabh Gaur
Saurabh Gaur

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

Related Questions