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
• 5,710 points
166 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

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
• 12,150 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
525 views
0 votes
1 answer

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

Okay, so let me talk about the ...READ MORE

answered Apr 2, 2018 in Selenium by nsv999
• 5,030 points
829 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
606 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,570 points
35 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,030 points
63 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
434 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
51 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
• 12,150 points
67 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.