@Override public Object getTarget() { return getContext(true).getWebDriver(); } };
private WebDriver getWebDriver() { return GrapheneContext.getContextFor(Default.class).getWebDriver(); } }
public static JavascriptExecutor getExecutorFromElement(WebElement element) { Preconditions.checkNotNull(element, "The element cannot be null."); if (element instanceof GrapheneProxyInstance) { GrapheneContext context = ((GrapheneProxyInstance) element).getGrapheneContext(); return (JavascriptExecutor) context.getWebDriver(JavascriptExecutor.class); } throw new RuntimeException( "Cannot obtain JavascriptExecutor from element which is not an instance of GrapheneProxyInstance."); }
@Override public Object getTarget() { return getContext(true).getWebDriver(); } };
private WebDriver getWebDriver() { return GrapheneContext.getContextFor(Default.class).getWebDriver(); } }
@Override public Object getTarget() { GrapheneContext context = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(annotations)); return context.getWebDriver(mediatorType); } };
@Override public Object getTarget() { GrapheneContext context = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(annotations)); return context.getWebDriver(mediatorType); } };
public WebDriverWait<Void> waitGui() { return waitGui(context().getWebDriver()); }
/** * Wraps the {@link WebDriver} instance provided by {@link Drone} in a proxy and sets the driver into context */ @Override public WebDriver enhance(WebDriver driver, Class<? extends Annotation> qualifier) { GrapheneContext grapheneContext = GrapheneContext.setContextFor(configuration.get(), driver, qualifier); Class<?>[] interfaces = GrapheneProxyUtil.getInterfaces(driver.getClass()); return grapheneContext.getWebDriver(interfaces); }
public WebDriverWait<Void> waitAjax() { return waitAjax(context().getWebDriver()); }
/** * Wraps the {@link WebDriver} instance provided by {@link Drone} in a proxy and sets the driver into context */ @Override public WebDriver enhance(WebDriver driver, Class<? extends Annotation> qualifier) { GrapheneContext grapheneContext = GrapheneContext.setContextFor(configuration.get(), driver, qualifier); Class<?>[] interfaces = GrapheneProxyUtil.getInterfaces(driver.getClass()); return grapheneContext.getWebDriver(interfaces); }
public <T> T goTo(Class<T> pageObject, Class<?> browserQualifier) { T result = null; GrapheneContext grapheneContext = GrapheneContext.getContextFor(browserQualifier); WebDriver browser = grapheneContext.getWebDriver(); try { result = PageObjectEnricher.setupPage(grapheneContext, browser, pageObject); } catch (Exception e) { throw new GrapheneTestEnricherException("Error while initializing: " + pageObject, e); } handleLocationOf(pageObject, browser); return result; }
@Override public void click(WebElement element) { new Actions(context().getWebDriver()).click(element).perform(); }
public <T> T goTo(Class<T> pageObject, Class<?> browserQualifier) { T result = null; GrapheneContext grapheneContext = GrapheneContext.getContextFor(browserQualifier); WebDriver browser = grapheneContext.getWebDriver(); try { result = PageObjectEnricher.setupPage(grapheneContext, browser, pageObject); } catch (Exception e) { throw new GrapheneTestEnricherException("Error while initializing: " + pageObject, e); } handleLocationOf(pageObject, browser); return result; }
@Override public void doubleClick(WebElement element) { new Actions(context().getWebDriver()).doubleClick(element).perform(); }
@Override public void click(WebElement element) { new Actions(context().getWebDriver()).click(element).perform(); }
@Test public void testContextVsDrone() { ((GrapheneProxyInstance) browser1).registerInterceptor(createInterceptor(counter1)); ((GrapheneProxyInstance) browser2).registerInterceptor(createInterceptor(counter2)); ((GrapheneProxyInstance) browserDefault).registerInterceptor(createInterceptor(counterDefault)); context1.getWebDriver().getTitle(); context2.getWebDriver().getTitle(); contextDefault.getWebDriver().getTitle(); Assert.assertEquals(1, counter1.get()); Assert.assertEquals(1, counter2.get()); Assert.assertEquals(1, counterDefault.get()); }
@Override protected void writeIntoElement(WebElement element, String text) { new Actions(context().getWebDriver()).moveToElement(element).click().sendKeys(text).perform(); }
@Test public void context_instance_should_be_instance_of_requested_driver() { assertTrue("context browser must be WebDriver", GrapheneContext.getContextFor(Default.class).getWebDriver() instanceof WebDriver); }
@Test public void context_instance_should_be_able_to_navigate_to_some_page() { GrapheneContext.getContextFor(Default.class).getWebDriver().navigate().to("http://127.0.0.1:4444"); } }