public By pickFrom(String method, String selector) {
    if ("class name".equals(method)) {
      return By.className(selector);
    } else if ("id".equals(method)) {
      return By.id(selector);
    } else if ("link text".equals(method)) {
      return By.linkText(selector);
    } else if ("partial link text".equals(method)) {
      return By.partialLinkText(selector);
    } else if ("name".equals(method)) {
      return By.name(selector);
    } else if ("tag name".equals(method)) {
      return By.tagName(selector);
    } else if ("xpath".equals(method)) {
      return By.xpath(selector);
    } else {
      throw new WebDriverException("Cannot find matching element locator to: " + method);
    }
  }