protected Optional<WebElement> getTargetElement() { if (where == null) { return Optional.empty(); } if (!(where.getCoordinates().getAuxiliary() instanceof WebElement)) { throw new IllegalStateException(String.format( "%s: Unable to find element to use: %s", this, where.getCoordinates())); } return Optional.of((WebElement) where.getCoordinates().getAuxiliary()); } }