code: public List<WebElement> locateElement(String method, String element,
                                            Integer expectedCount) throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
  
          List<WebElement> wel = null;
  
          if ("id".equals(method)) {
              logger.debug("Locating {} by id", element);
              wel = this.getDriver().findElements(By.id(element));
          } else if ("name".equals(method)) {
              logger.debug("Locating {} by name", element);
              wel = this.getDriver().findElements(By.name(element));
          } else if ("class".equals(method)) {
              logger.debug("Locating {} by class", element);
              wel = this.getDriver().findElements(By.className(element));
          } else if ("xpath".equals(method)) {
              logger.debug("Locating {} by xpath", element);
              wel = this.getDriver().findElements(By.xpath(element));
          } else if ("css".equals(method)) {
              wel = this.getDriver().findElements(By.cssSelector(element));
          } else {
              fail("Unknown search method: " + method);
          }
  
          if (expectedCount != -1) {
              PreviousWebElements pwel = new PreviousWebElements(wel);
              assertThat(this, pwel).as("Element count doesnt match").hasSize(expectedCount);
          }
  
          return wel;
      }
docs: Looks for webelements inside a selenium context. This search will be made
  by id, name and xpath expression matching an {@code locator} value
  
  @param method        class of element to be searched
  @param element       webElement searched in selenium context
  @param expectedCount integer. Expected number of elements.
  @return List(WebElement)
  @throws IllegalAccessException   exception
  @throws IllegalArgumentException exception
  @throws SecurityException        exception
  @throws NoSuchFieldException     exception
  @throws ClassNotFoundException   exception