selenium locator by css code example
Example 1: locators in selenium
- There are 8 locators.
- id, class, name, linktext, partialLinktext,
cssSelector, xpath, tagName
- First I would check for id. If there is id,
and it is not dynamic, I would go for id.
- If not, I would quickly check for it if
there is unique class or name attribute value
-If it is link, I would use linkText or
partiallinktext
-If none available than I would go for xpath
Example 2: css selenium
elementcss= driver.findElement(By.cssSelector('div.nav-search-input'))