Monday, November 3, 2014

CSS Selectors for WebDriver

CSS Selectors for WebDriver

Selenium WebDriver uses CSS selectors to locate elements in DOM. CSS selectors is much faster and way more reliable way to locate the elements as compared to XPaths. Selenium WebDriver’s By class provides the cssSelector() method for locating elements using CSS selectors. [Selenium Testing Tools Cookbook By Unmesh Gundecha]

Selenium WebDriver’s CSS selector / locator strategy is useful as:
- It is helpful across browsers.
- It reduces lines of code as compared to XPath.
- Its faster.

Below are some very useful links on using CSS Selector with WebDriver:

1. How to Use CSS Selector for Identifying Web Elements for Selenium Scripts. [Link]
2. Selenium Tips: CSS Selectors. [Link]
3. CSS selectors for Selenium with example. [Link]
4. Need to find element in selenium by css. [Link]
5. Selenium Webdriver API. [Link]
6. CSS Locator Reference/Cheat Sheet for XPath people. [Link]
7. CSS Selectors and You. [Link]
8. Selenium WebDriver issue with By.cssSelector. [Link]
9. Handling Compound Classes using CSS Selectors. [Link]
10. CSS Locator / CSS Selector Tutorial. [Link]
11. A way to match on text using CSS locators. [Link]
12. CSS selectors and selenium (webdriver). [Link]
13. Css selector - BNT 11. [Link]
14. Effective use of selectors in Selenium Webdriver. [Link]