October 2018
Intermediate to advanced
192 pages
5h 12m
English
The way ByIdOrName works is that the ID takes precedence. If a particular element is not found with the ID that is specified, the search is made based on a name. If the element is not found after the second search, it throws a NoSuchElementException.
Let's have a look at the code to handle this.
The following code uses an implicit wait of 30 seconds for each element on the page. First, it searches based on the ID and then on the name. Notice that we have to invoke the constructor in order to use this locator:
public class ByIdOrNameDemo { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "\\src\\main\\resources\\chromedriver.exe"); WebDriver driver ...Read now
Unlock full access