protected WebElement findElement(String by, String using) { if (using == null) { throw new IllegalArgumentException("Cannot find elements when the selector is null."); } Response response = execute(DriverCommand.FIND_ELEMENT, ImmutableMap.of("using", by, "value", using)); WebElement element = (WebElement) response.getValue(); setFoundBy(this, element, by, using); return element; }
@SuppressWarnings("unchecked") protected List<WebElement> findElements(String by, String using) { if (using == null) { throw new IllegalArgumentException("Cannot find elements when the selector is null."); } Response response = execute(DriverCommand.FIND_ELEMENTS, ImmutableMap.of("using", by, "value", using)); List<WebElement> allElements = (List<WebElement>) response.getValue(); for (WebElement element : allElements) { setFoundBy(this, element, by, using); } return allElements; }