question

gkarumba avatar image
gkarumba asked ericnute edited

Is there any easy/quick way to get the XPATH of an object from showPage/snapshot output?

Is there any easy/quick way to get the XPATH of an object from showPage/snapshot output?

iTestGUI Testing(Web-Java Swing-etc)xpath
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
PreetS avatar image
PreetS answered PreetS posted

Hi gkarumba,

 

One of the quick and easy ways to find a 'target' query to a particular control on a web page is using the 'Target Selection Helper' built into the iTest web editor. Open up the web session and just browse to the page on which the target you are looking for is located.  Now on the top right corner of the browser toolbar, click on the 'Select Target' button. This will set the browser to a target selection mode. Now, just click on any object on the web page, you will see that it gets highlighted and the statusbar of the browser will show the xpath target to that element on the web page. To copy the target to the clipboard, double click on the element on the web page. Now you can paste this in your test case in any step you are adding/editing.

 

 

 

Also, you could also extract targets from the XML output of a 'snapshot' command. (Note: you should never use showPage for this, as showPage gives your the static HTML content of the page, while snapshot will  give you thecurrent DOM as XML).One way is to use the Structure view of a snapshot step. When you click on various elements in the XML structure of the page, it will create a top-down XPATH query for you. You could also paste the XML in any freely available third party XPATH utility to help you create custom XPATHs. 

 

 

1 comment
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

PreetS avatar image PreetS commented ·
By the way, this is the screenshot showing how to get in to the 'target selection mode'
0 Likes 0 ·
f1.JPG (15.1 KiB)

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.