@Override public boolean equals(Object obj) { if (!(obj instanceof WebElement)) { return false; } WebElement other = (WebElement) obj; if (other instanceof WrapsElement) { other = ((WrapsElement) obj).getWrappedElement(); } return other instanceof HtmlUnitWebElement && element.equals(((HtmlUnitWebElement) other).element); }
@Override public boolean equals(Object obj) { if (!(obj instanceof WebElement)) { return false; } WebElement other = (WebElement) obj; if (other instanceof WrapsElement) { other = ((WrapsElement) other).getWrappedElement(); } return element.equals(other); }
@Override public boolean equals(Object obj) { if (!(obj instanceof WebElement)) { return false; } WebElement other = (WebElement) obj; if (other instanceof WrapsElement) { other = ((WrapsElement) other).getWrappedElement(); } return underlyingElement.equals(other); }
@Override public boolean equals(Object obj) { if (!(obj instanceof WebElement)) { return false; } WebElement other = (WebElement) obj; if (other instanceof WrapsElement) { other = ((WrapsElement) other).getWrappedElement(); } return underlyingElement.equals(other); }
@Override protected boolean matchesSafely(WrapsElement element) { return matcher.matches(element.getWrappedElement()) || matcher.matches(element); }
@Override protected boolean matchesSafely(WrapsElement element) { return matcher.matches(element.getWrappedElement()) || matcher.matches(element); }
private WebElement unwrapWebElement(WebElement element) { while (element instanceof WrapsElement) { element = ((WrapsElement) element).getWrappedElement(); } return element; } }
public WebDriver frame(WebElement frameElement) { DomWindow window = executeFrameSwitchingJs("return arguments[0].contentWindow;", ((WrapsElement) frameElement).getWrappedElement()); currentWindowOrFrame = window; return AndroidWebDriver.this; }
/** * Assert that the two elements are equal. * <p> * Can be removed if https://dev.vaadin.com/ticket/18484 is fixed. * * @param expectedElement * the expected element * @param actualElement * the actual element */ protected static void assertEquals(WebElement expectedElement, WebElement actualElement) { WebElement unwrappedExpected = expectedElement; WebElement unwrappedActual = actualElement; while (unwrappedExpected instanceof WrapsElement) { unwrappedExpected = ((WrapsElement) unwrappedExpected) .getWrappedElement(); } while (unwrappedActual instanceof WrapsElement) { unwrappedActual = ((WrapsElement) unwrappedActual) .getWrappedElement(); } Assert.assertEquals(unwrappedExpected, unwrappedActual); }
@Override protected void describeMismatchSafely(WrapsElement element, Description mismatchDescription) { matcher.describeMismatch(element.getWrappedElement(), mismatchDescription); }
/** * Unwraps the WebElement of an Element. <br/> * In order to do so, the element must implement WrapsElement. (Notice: wiselenium elements' * proxies already implement it.) * * @param element The element. * @return The WebElement decorated by the Element. * @since 0.1.0 */ public static WebElement unwrapWebElement(Object element) { if (element instanceof WrapsElement) return ((WrapsElement) element).getWrappedElement(); throw new WebElementNotWrappedException(element); }
@Override protected void describeMismatchSafely(WrapsElement element, Description mismatchDescription) { matcher.describeMismatch(element.getWrappedElement(), mismatchDescription); }
/** * Gets the wrapped element of an element. There's a chance the element is already enhanced, so * it must invoke its proper getWrappedElement() method. * * @param <E> The element type. * @param element The element. * @return The wrapped element of the element. * @since 0.1.0 */ public static <E> Object getWrappedElement(E element) { if (!Enhancer.isEnhanced(element.getClass())) return element; return ((WrapsElement) element).getWrappedElement(); }
@Override public boolean equals(Object o) { if (!(o instanceof WebElement)) { return false; } WebElement e = (WebElement) o; if (e instanceof WrapsElement) { e = ((WrapsElement) o).getWrappedElement(); } if (!(e instanceof AndroidWebElement)) { return false; } return elementId.equals(((AndroidWebElement) e).getId()); }
@Override public boolean equals(Object obj) { if (!(obj instanceof WebElement)) { return false; } WebElement other = (WebElement) obj; if (other instanceof WrapsElement) { other = ((WrapsElement) obj).getWrappedElement(); } if (!(other instanceof ChromeWebElement)) { return false; } Object result = parent.executeScript("return arguments[0] === arguments[1]", this, other); return result != null && result instanceof Boolean && (Boolean) result; } }
@Override public boolean equals(Object obj) { if (!(obj instanceof WebElement)) { return false; } WebElement other = (WebElement) obj; if (other instanceof WrapsElement) { other = ((WrapsElement) obj).getWrappedElement(); } if (!(other instanceof InternetExplorerElement)) { return false; } Boolean result = (Boolean) parent.executeScript("return arguments[0] === arguments[1];", this, other); return result != null && result; }
private void execDecorativeScript(JavascriptExecutor scriptExecutor, WebElement element, String script) throws InterruptedException { try { scriptExecutor.executeScript(script, element); } catch (ClassCastException e) { scriptExecutor.executeScript(script, ((WrapsElement) element).getWrappedElement()); } Thread.sleep(100); }
private void execDecorativeScript(JavascriptExecutor scriptExecutor, WebElement element, String script) throws InterruptedException { try { scriptExecutor.executeScript(script, element); } catch (ClassCastException e) { scriptExecutor.executeScript(script, ((WrapsElement) element).getWrappedElement()); } Thread.sleep(100); }
private TestBenchElement setLocalFileDetector() { TestBenchElement uploadElement = getUploadElement(); WebElement realUploadElement = uploadElement; while (realUploadElement instanceof WrapsElement) { realUploadElement = ((WrapsElement) realUploadElement) .getWrappedElement(); } if (realUploadElement instanceof RemoteWebElement) { ((RemoteWebElement) realUploadElement) .setFileDetector(new LocalFileDetector()); } else { throw new IllegalArgumentException("Expected argument of type " + RemoteWebElement.class.getName() + ", received " + realUploadElement.getClass().getName()); } return uploadElement; }
private WebElement getUnwrapped() { // we could get this type currently with executor.executeScript("return document.getElementById('...')"); // but this could easily change (ARQGRA-494), so we'll just unwrap the enriched element ourselves WebElement unwrapped = enriched; while (unwrapped instanceof WrapsElement) { unwrapped = ((WrapsElement) unwrapped).getWrappedElement(); } if (unwrapped instanceof GrapheneElement || unwrapped instanceof GrapheneProxyInstance) { // it's not right to use asserts here - not the point of the test // also a caller might use @Test(expected = AssertionError.class) throw new RuntimeException("Not unwrapped enough: " + unwrapped.getClass()); } return unwrapped; }