Need to know the differences between .// and //* in XPath?

0 votes

When using Firebug for getting relative XPath, I get something like this:

.//*[@id='Passwd']

My question is, what does the dot at the start signify? And also, what does '//*' signify? Especially, from below examples of Gmail, What is its significance?

.//*[@id='Passwd']

//child::input[@type='password']
Apr 29, 2018 in Selenium by Martin
• 4,210 points
407 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

The expressions your talking about, select different nodesets:-

.//*[@id='Passwd']

The '.' at the start inndicates that the processing will start from the current node. 
The '*' is used for selecting all the element nodes descending from the current node with @id-attribute-value equal to 'Passwd'.

W.R.T to your first questions, if we don't use '.' (dot) at the beginning, then you will be basically selecting all element nodes with an @id-attribute-value equal to 'Passwd' from the entire document.
By adding '//*' in XPath you would be selecting all the element nodes from the entire document.

In case of the Gmail Password fields, .//*[@id='Passwd'] would select all the element nodes descending from the current node for which @id-attribute-value is equal to 'Passwd'. But, //child::input[@type='password'] would select all child-element nodes named input for which @type-attribute-values are equal to 'password'. The child:: axis prefix may be omitted, because it is the default behaviour.

answered Apr 29, 2018 by king_kenny
• 3,590 points

Related Questions In Selenium

0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,050 points
3,895 views
0 votes
2 answers
0 votes
1 answer

Need to switch between frames in Selenium

For switching between frames, use driver.switchTo().frame(). First ...READ MORE

answered Apr 6, 2018 in Selenium by nsv999
• 5,050 points
472 views
0 votes
1 answer

What's the difference between functions getClass() and getAttribute(“class”) in Selenium?

The simple difference is that, getClass() returns ...READ MORE

answered Apr 7, 2018 in Selenium by nsv999
• 5,050 points
2,127 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
145 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
540 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
138 views
0 votes
1 answer

What is the difference between dot and text() in XPath?

Even though there is some difference between ...READ MORE

answered Apr 25, 2018 in Selenium by king_kenny
• 3,590 points
834 views
0 votes
1 answer

Need to control the file download dialog box in Mozilla Firefox

Well for Firefox, there is something called ...READ MORE

answered Apr 20, 2018 in Selenium by king_kenny
• 3,590 points
99 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.