question: private static By byFromLocator ( String locator ) { if ( locator . startsWith ( "//" ) ) { return By . xpath ( locator ) ; } if ( locator . startsWith ( "id=" ) ) { return By . id ( locator . replaceFirst ( "id=" , "" ) ) ; } if ( locator . startsWith ( "css=" ) ) { return By . cssSelector ( locator . replaceFirst ( "css=" , "" ) ) ; } if ( locator . startsWith ( "xpath=" ) ) { return By . xpath ( locator . replaceFirst ( "xpath=" , "" ) ) ; } if ( locator . startsWith ( "name=" ) ) { return By . name ( locator . replaceFirst ( "name=" , "" ) ) ; } if ( locator . startsWith ( "link=" ) ) { return By . linkText ( locator . replaceFirst ( "link=" , "" ) ) ; } if ( locator . startsWith ( "linkpartial=" ) ) { return By . partialLinkText ( locator . replaceFirst ( "linkpartial=" , "" ) ) ; } throw new IllegalArgumentException ( "Locator not supported: " + locator ) ; }
target:  Converts a locator string with a known prefix to a By object