Home > Enterprise >  What is By in Selenium
What is By in Selenium

Time:04-18

driver.findElement(By.id(//[@id='kishr']));

What is By above?

Is this class ,reference or object ?

CodePudding user response:

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.

Official docs

CodePudding user response:

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,

  • Related