Wipro interview question

What is Difference between XPath and CSS Selectors in Selenium WebDriver

Interview Answers

Anonymous

19 Jan 2020

Major Difference I see is CSS Selector is faster then Relative Xpath. Relative XPath tends to find multiple elements and used in special case only. He asked like there is one major difference can you tell that. I couldn't answer that as I told I have used id and name selector more than CSS selector.

2

Anonymous

12 June 2021

In Xpath you can traverse backward and forward as per your need but in CSS you can only move forward. Also Xpath can be created by using text() but there is no such way of finding element in CSS CSS is faster comparatively.

1