public By defineByElement ( ) { // consider adding strengthening By byElement = null ; switch ( type ) { // determine which locator type we are interested in case XPATH : byElement = By . xpath ( locator ) ; break ; case ID : byElement = By . id ( locator ) ; break ; case NAME : byElement = By . name ( locator ) ; break ; case CLASSNAME : byElement = By . className ( locator ) ; break ; case CSS : byElement = By . cssSelector ( locator ) ; break ; case LINKTEXT : byElement = By . linkText ( locator ) ; break ; case PARTIALLINKTEXT : byElement = By . partialLinkText ( locator ) ; break ; case TAGNAME : byElement = By . tagName ( locator ) ; break ; } return byElement ; }
Determines Selenium s By object using Webdriver