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,220 points
679 views

1 answer to this question.

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,650 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,090 points
5,080 views
0 votes
2 answers
0 votes
1 answer
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,090 points
756 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,090 points
544 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
880 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
537 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,650 points
1,174 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,650 points
144 views