'What is By in Selenium
driver.findElement(By.id(//[@id='kishr']));
What is By above?
Is this class ,reference or object ?
Solution 1:[1]
By is an abstract class
and
id is a static method, so is linkText, partialLinkText, name, tagName, xpath, className, cssSelector in By abstract class.
Since it's a class level methods, you don't really need an object to call these methods.
By.id or By.xpath etc. should suffice.
Solution 2:[2]
By is an abstract class its provides a way to various search criteria's to locate the locator, it provides 8 method for 8 locator stategies,All 8 method are static so call them we have to use class name,
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | cruisepandey |
| Solution 2 | milan ahrivastava |
