Skip to main content

Posts

Showing posts with the label fallback

3 Selenium classes that are not so popular to locate elements

Here we have discussed 3 Selenium classes that are not so popular but that can help you locate elements in Selenium: - ByIdOrName - ByChained - ByAll 1) ByIdOrName - This helps the driver to locate an element either by name or by id. This is present under org.openqa.selenium.support package and to use this we have to call the constructor of the ByIdOrName class and pass the Name or ID. This method tries to find the element using ID first and it waits till the max implicit wait time for the element to locate using ID and if it is not able to find the element with ID then only it tries to locate with the Name. As soon as the driver finds the element with id, it will not check the element with a name attribute and won't want for max implicit wait time either. driver.findElement(new ByIdOrName("username")).click(); 2) ByChained - This helps the driver to locate the element based on the parent element, and it accepts an unlimited number of locators. This is prese...