What is the primary difference between the XPath and CSS selector

0 votes
What is the primary difference between the XPath and CSS selector?
Jun 21, 2019 in Selenium by Ushma
21,115 views

1 answer to this question.

0 votes

Hello Ushma, the primary difference between XPath and CSS Selectors is that, with the XPath we can traverse both forward and backward whereas CSS selector only moves forward. Although CSS selectors perform far better than Xpath and it is well documented in Selenium community. It has following advantages over XPath as:

  • Xpath engines are different in each browser, hence make them inconsistent

  • IE does not have a native xpath engine, therefore selenium injects its own xpath engine for compatibility of its API. Thus losing the advantage of using native browser features.

  • Xpath tend to become complex and hence make hard to read.

However there are some situations where, you need to use xpath, like while searching for a parent element or searching element by its text.

 

answered Jun 23, 2019 by Anvi
• 14,150 points

Related Questions In Selenium

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
4,847 views
0 votes
3 answers

What is the difference between relative and absolute XPath?

Absolute Xpath: It contains the complete path ...READ MORE

answered Dec 19, 2018 in Selenium by Nabarupa
28,472 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
12,788 views
0 votes
1 answer

What is the difference between thoughtworks.selenium and openqa.selenium selenium?

thoughtworks.selenium is the original Selenium (aka Selenium 1, ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,710 points
1,352 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,520 points
5,089 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,010 points
5,824 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
3,595 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 2, 2020 in Selenium by Sri
• 3,010 points
4,334 views
+1 vote
2 answers

What is the difference between findElement and findElements in Selenium Webdriver?

FindElement Command -This method locates for the ...READ MORE

answered Feb 10, 2020 in Selenium by anonymous
3,921 views
0 votes
1 answer

What is the difference between getWindowHandle() and getWindowHandles() methods in Selenium WebDriver?

Hey Jennifer, difference between getWindowHandle() and getWindowHandles() ...READ MORE

answered Jun 3, 2019 in Selenium by Anvi
• 14,150 points
8,362 views