-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Selenium Testing Tools Cookbook Second Edition
By :
Finding elements in Selenium WebDriver is done by using the findElement() and findElements() methods provided by the WebDriver and WebElement interface.
The findElement() method returns an instance of a WebElement that is found in the page DOM based on specified locators, also called search criteria. If it does not find an element using the specified search criteria, it will throw the NoSuchElementFound exception.
The findElements() method returns a list of WebElements matching the search criteria. If no elements are found, it returns an empty list.
Find methods take a locator or a query object as an instance of a By class as an argument. Selenium WebDriver provides a By class to support various locator strategies. The following table lists various locator strategies supported by Selenium WebDriver:
|
Strategy |
Syntax |
Description |
|---|---|---|
|
By ID |
Java: C#: Python... |
Change the font size
Change margin width
Change background colour