### Question:
HtmlElementUtils { public static By getFindElementType(String locator) { logger.entering(locator); Preconditions.checkArgument(StringUtils.isNotBlank(locator), INVALID_LOCATOR_ERR_MSG); By valueToReturn = null; String seleniumLocator = locator.trim(); int typeDelimiterIndex = seleniumLocator.indexOf('='); String locatorType = typeDelimiterIndex != -1 ? seleniumLocator.substring(0, typeDelimiterIndex) : seleniumLocator; switch (locatorType) { case "id": valueToReturn = By.id(seleniumLocator.substring(typeDelimiterIndex + 1)); break; case "name": valueToReturn = By.name(seleniumLocator.substring(typeDelimiterIndex + 1)); break; case "link": valueToReturn = By.linkText(seleniumLocator.substring(typeDelimiterIndex + 1)); break; case "xpath": valueToReturn = By.xpath(seleniumLocator.substring(typeDelimiterIndex + 1)); break; case "css": valueToReturn = By.cssSelector(seleniumLocator.substring(typeDelimiterIndex + 1)); break; case "classname": valueToReturn = By.className(seleniumLocator.substring(typeDelimiterIndex + 1)); break; default: if (seleniumLocator.startsWith("/") || seleniumLocator.startsWith("./")) { valueToReturn = By.xpath(seleniumLocator); break; } valueToReturn = new ByIdOrName(seleniumLocator); } if (logger.isLoggable(Level.FINE)) { String msg = valueToReturn.getClass().getSimpleName() + " will be the location strategy that will be used for locating " + seleniumLocator; logger.log(Level.FINE, msg); } logger.exiting(valueToReturn); return valueToReturn; } private  HtmlElementUtils(); static RemoteWebElement locateElement(String locator); static RemoteWebElement locateElement(String locator, ParentTraits parent); static List<WebElement> locateElements(String locator); static List<WebElement> locateElements(String locator, ParentTraits parent); static void isValidXpath(String locator); static By resolveByType(String locator); static By getFindElementType(String locator); static boolean isElementPresent(String locator);  }### Answer:
@Test(groups = { "unit" }) public void validateFindElementType() { HashMap<String, String> myElements = new HashMap<String, String>(); myElements.put("id=foo", ById.class.getCanonicalName()); myElements.put("name=foo", ByName.class.getCanonicalName()); myElements.put("link=foo", ByLinkText.class.getCanonicalName()); myElements.put("xpath=foo", ByXPath.class.getCanonicalName()); myElements.put("/foo", ByXPath.class.getCanonicalName()); myElements.put(" myElements.put(". myElements.put("css=foo", ByCssSelector.class.getCanonicalName()); myElements.put("foo", ByIdOrName.class.getCanonicalName()); Iterator<String> allElements = myElements.keySet().iterator(); while (allElements.hasNext()) { String eachElement = allElements.next(); By b = HtmlElementUtils.getFindElementType(eachElement); assertTrue(b.getClass().getCanonicalName().equals(myElements.get(eachElement))); } }