private WebDriver getWebDriver() { return GrapheneContext.getContextFor(Default.class).getWebDriver(); } }
private WebDriver getWebDriver() { return GrapheneContext.getContextFor(Default.class).getWebDriver(); } }
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { return GrapheneContext.getContextFor(ReflectionHelper.getQualifier(qualifiers)); }
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { return GrapheneContext.getContextFor(ReflectionHelper.getQualifier(qualifiers)); }
@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); } };
/** * Returns active (focused) element - if no element is focused (it means body element is active), null is returned */ public static WebElement retrieveActiveElement() { GrapheneContext context = GrapheneContext.getContextFor(Default.class); WebElement element = JSInterfaceFactory.create(context, FocusRetriever.class).getActiveElement(); if ("body".equals(element.getTagName())) { return null; } return element; } }
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { GrapheneContext context = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(qualifiers)); try { return context.getWebDriver(Class.forName(getReturnType())); } catch (ClassNotFoundException ex) { //the external users: // - does not have any chance to build a test with classes which are not added on classpath //the intern usage of Providers: // - the class path may contain a different version of Selenium // - problem with internal use of Actions, Javascript, Mouse throw new IllegalStateException("The class of the provider is not on the class path.", ex); } } }
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { GrapheneContext context = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(qualifiers)); try { return context.getWebDriver(Class.forName(getReturnType())); } catch (ClassNotFoundException ex) { //the external users: // - does not have any chance to build a test with classes which are not added on classpath //the intern usage of Providers: // - the class path may contain a different version of Selenium // - problem with internal use of Actions, Javascript, Mouse throw new IllegalStateException("The class of the provider is not on the class path.", ex); } } }
private WebDriver getTakingScreenshotsBrowser(File screenshotToTake) { WebDriver result = null; try { GrapheneContext context = GrapheneContext.getContextFor(Default.class); result = ((GrapheneProxyInstance) context.getWebDriver(TakesScreenshot.class)).unwrap(); //FIXME remove this try-catch block and bring new solution } catch (IllegalStateException ex) { log.info("The screenshot " + screenshotToTake.getPath() + " hasn't been taken." + " The reason: " + ex.getMessage()); return null; } if (result instanceof ReusableRemoteWebDriver) { result = new Augmenter().augment(result); } return result; }
private WebDriver getTakingScreenshotsBrowser(File screenshotToTake) { WebDriver result = null; try { GrapheneContext context = GrapheneContext.getContextFor(Default.class); result = ((GrapheneProxyInstance) context.getWebDriver(TakesScreenshot.class)).unwrap(); //FIXME remove this try-catch block and bring new solution } catch (IllegalStateException ex) { log.info("The screenshot " + screenshotToTake.getPath() + " hasn't been taken." + " The reason: " + ex.getMessage()); return null; } if (result instanceof ReusableRemoteWebDriver) { result = new Augmenter().augment(result); } return result; }
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; }
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; }
@Test(expected = IllegalArgumentException.class) public void factory_should_fail_when_class_provided() { InvalidClass instance = JSInterfaceFactory.create(GrapheneContext.getContextFor(Default.class), InvalidClass.class); } }
@Before public void prepare() { handler = GrapheneContextualHandler.forTarget(GrapheneContext.getContextFor(Default.class), null); }
@Test public void factory_should_create_valid_instance_of_given_interface() { TestingInterface instance = JSInterfaceFactory.create(GrapheneContext.getContextFor(Default.class), TestingInterface.class); assertTrue("instance should implement the provided interface", instance instanceof TestingInterface); }
@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"); } }
@Test public void testHttp() { RequestGuard guard = JSInterfaceFactory.create(GrapheneContext.getContextFor(Default.class), RequestGuard.class); assertEquals(RequestType.HTTP, guard.getRequestType()); guard.clearRequestDone(); assertEquals(RequestType.NONE, guard.getRequestType()); http.click(); assertEquals(RequestType.HTTP, guard.getRequestType()); }
@Test public void testXhr() throws InterruptedException { RequestGuard guard = JSInterfaceFactory.create(GrapheneContext.getContextFor(Default.class), RequestGuard.class); assertEquals(RequestType.HTTP, guard.getRequestType()); guard.clearRequestDone(); assertEquals(RequestType.NONE, guard.getRequestType()); xhr.click(); waitAjax().until().element(status).text().contains("DONE"); assertEquals(RequestType.XHR, guard.getRequestType()); }