Xpath queries

102 views
Skip to first unread message

pankaj d

unread,
Aug 19, 2015, 3:39:08 AM8/19/15
to seleniu...@googlegroups.com


1. Which is best way to get xpath? Get using FF addons or creating our own xpath?

2. While creating Xpath, how to dentify unique id?
What to do if unique id is not available?

3. What means of .//* in following xpath?
.//*[@id='header']/ul[1]/li[2]/a

Kaleem Uddin Mohammed Abdul

unread,
Aug 19, 2015, 6:20:12 AM8/19/15
to Selenium Users
My friend, this group is related to Selenium not about XPath. Google is your best friend for your queries.

You can go throw http://www.w3schools.com/xsl/xpath_intro.asp
for learning Xpath.


On Wednesday, August 19, 2015 at 1:09:08 PM UTC+5:30, pankaj d wrote:


1. Which is best way to get xpath? Get using FF addons or creating our own xpath?

<Kaleem>:All are best. But it should be very simple instead of identifying usingindex hence I prefer building xpath.

2. While creating Xpath, how to dentify unique id?
What to do if unique id is not available?

<Kaleem>:If Unique id is not available you should go for some unique attribute.

3. What means of .//* in following xpath?
.//*[@id='header']/ul[1]/li[2]/a

<Kaleem>:Double Slash means anywhere in the HTMLDOM and * indicates any HTML tag.

Pankaj D

unread,
Aug 19, 2015, 11:52:32 AM8/19/15
to Selenium Users

Thanks frnd for reply. but I think we use xpath is in selenium also. Please let me know if you know about my quries

On Wednesday, August 19, 2015 at 1:09:08 PM UTC+5:30, pankaj d wrote:

Braja

unread,
Aug 19, 2015, 2:17:52 PM8/19/15
to Selenium Users
1) FF Addons

Travis

unread,
Aug 19, 2015, 4:54:47 PM8/19/15
to Selenium Users
1. I mostly use Firebug.  It's easy to use and lets you check your xpath to make sure it's finding what you want it to find.

2. Look for the "id" attribute of the HTML element.  It's not guaranteed to be unique, but that's up to the developers who made the page.  So, for example, if you have this:
       <input id="submitbutton">
the id is "submitbutton".

3. This is a good explanation of .// usage, and the * just means "any element node."  .//* means something like "starting from the current node (.), looking at all descendants (//) and find any element (*)".

Andy Suarez

unread,
Aug 19, 2015, 4:54:47 PM8/19/15
to Selenium Users
1. As far as a xPath identification source, FF does its job. It won't vary much you might have some conditional /?/ which is simply reg expression for there can be one conditional layer in path. (Xpath Master :))
2. If there is no specific unique id, you could use another form of identification, CSS, ect. You can also  identify via several other properties of the sepcfic element.
3. It means that under whatever base element you are choosing go as deep into the object tree as need be to find a element with the ID of ect..... :)

Please let me know if you have any other questions :)

Andy Suarez
Test Automation Engineer 
xPath Goru :)

Ripon Al Wasim

unread,
Aug 20, 2015, 1:48:59 AM8/20/15
to seleniu...@googlegroups.com
For getting xpath you can use Firebug and Firepath. You can get both absolute and relative xpath by using Firepath. If you want you can write you own xpath.

single / is for absolute xpath and double slash (//) is for relative xpath.

Ripon

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAD%2BfA_0oTjK5Q-bhd5weCu7PDFX49-iuC-yKTfeDNOYRWL-qnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Vladislav Lopatynsky

unread,
Aug 20, 2015, 2:48:29 AM8/20/15
to Selenium Users
Hi!
If you will have in the future big dedicated test system, try not to use absolute paths. Because it becomes so hard to maintain it. Always try to make it more understandable and short

Ripon Al Wasim

unread,
Aug 20, 2015, 2:50:07 AM8/20/15
to seleniu...@googlegroups.com
Yes, using Relative xpath is the better and recommended.

Kaleem Uddin Mohammed Abdul

unread,
Aug 20, 2015, 4:50:35 AM8/20/15
to Selenium Users
The concept of Selenium is same which is mentioned in W3Schools and Selenium.

jishan alam

unread,
Aug 21, 2015, 10:51:19 PM8/21/15
to Selenium Users

1. Which is best way to get xpath? Get using FF addons or creating our own xpath?


    Ans : Best way of getting Xpath is to write Xpath  viewing  the HTML DOM.You should have some basic knowledge of HTML language.
             No FF addons generate "Absolute Xpath" which will not work if any changes done.you should go for "Relative Xpath"


   2. While creating Xpath, how to dentify unique id?
       What to do if unique id is not available?

  Ans: For this always go for "id" attribute.If unique attribute is not available then write Xpath using parent-child relationship.In elaborate if you cannot find unique attribute the find what is parent category and go upto               that  level where you can find unique.
          


    3. What means of .//* in following xpath?
    .//*[@id='header']/ul[1]/li[2]/a

  Ans: "//" means go through the entire HTML document.my request is that don't use this format ("Absolute Xpath") of Xpath in beginning.This is a bit confusing.

If any problem.post in group
   
Reply all
Reply to author
Forward
0 new messages