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,330 points
3,286 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,710 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,500 points
13,043 views
0 votes
2 answers

What is the difference between / and // in xpath?

/ - Selects from the root node // ...READ MORE

answered May 29, 2019 in Selenium by anonymous
15,344 views
0 votes
1 answer

What are the differences between POM and PageFactory in Selenium Webdriver?

Hi Raveena, Page Object Model (POM) and ...READ MORE

answered Jul 17, 2019 in Selenium by Anvi
• 14,150 points
16,936 views
0 votes
0 answers

Getting Java Null Pointer Exception on running the test case in Seleniumn.Can someone pls let me know where i need to fix in order to progress

Below is the Error: java.lang.RuntimeException: java.lang.NullPointerException at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:49) at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:131) at ...READ MORE

Sep 11, 2020 in Selenium by sandhya
• 180 points
3,118 views
0 votes
2 answers

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,500 points
6,019 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
6,457 views
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,890 points
4,083 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
5,056 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,710 points
5,526 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 21, 2018 in Selenium by king_kenny
• 3,710 points
1,860 views