Which is better CSS or Xpath? Considering performance and cross browser testing

0 votes
I was using Selenium for my web application for the testing the page content. For this which is better according to performance & which supports all the browsers (i.e. IE 7,8,9, FF, Chrome etc).
Apr 17, 2018 in Selenium by code_ninja
• 6,160 points
230 views

1 answer to this question.

0 votes

According to css has better performance compared to xpath and it is well documented in Selenium community. Here are some reasons,

  • 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. Hence we lose the advantage of using native browser features that WebDriver inherently promotes.
  • Xpath tend to become complex and hence make hard to read in my opinion

In case of searching for a parent element or searching element by its text xpath would be preferred.

answered Apr 17, 2018 by Shubham
• 13,190 points

Related Questions In Selenium

0 votes
1 answer

Between By.XPath and By.ID, which is the better for locating elements?

Technically speaking, By.ID() is the faster technique ...READ MORE

answered May 29, 2018 in Selenium by sniffy_god
• 760 points
909 views
0 votes
2 answers

How different/ similar are Protractor and Selenium? Which is better?

Protractor and Selenium both are used to ...READ MORE

answered Jun 9 in Selenium by Amod Mahajan
1,088 views
0 votes
1 answer

Which is preferred more in Selenium Absolute or Relative XPath

Absolute XPath is the direct way to ...READ MORE

answered Apr 20, 2018 in Selenium by Meci Matt
• 9,400 points
813 views
0 votes
1 answer
0 votes
1 answer

What is cross browser testing?

Cross browser compatibility is the ability of ...READ MORE

answered Mar 25 in Selenium by Frankie
• 9,810 points
46 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
259 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
628 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
256 views
0 votes
1 answer

30 min Wait on a page and then perform any Operation using Selenium Webdriver

Implicit wait tells webdriver to poll the ...READ MORE

answered Apr 19, 2018 in Selenium by Shubham
• 13,190 points
92 views