/** * Creates a Test Browser. * * @param of the web driver to run the browser with. * @param port the port to run against http://localhost * @return the test browser. */ public static TestBrowser testBrowser(WebDriver of, int port) { return new TestBrowser(of, "http://localhost:" + port); }
/** * Repeatedly applies this instance's input value to the given function until one of the following occurs: * the function returns neither null nor false, * the function throws an unignored exception, * the default timeout expires * * useful in situations where FluentAdapter#await is too specific * (for example to check against page source or title) * * @param f function to execute */ public <T>T waitUntil(Function<WebDriver, T> f) { FluentWait<WebDriver> wait = fluentWait().withTimeout(3000, TimeUnit.MILLISECONDS); return waitUntil(wait,f); }
@After public void quitBrowser() { if (browser != null) { browser.quit(); browser = null; } } }
/** * Quits and releases the {@link WebDriver} */ void quit() { if (getDriver() != null) { getDriver().quit(); } releaseFluent(); } }
/** * A test browser (Using Selenium WebDriver) with the FluentLenium API (https://github.com/Fluentlenium/FluentLenium). * * @param webDriver The WebDriver instance to use. * @param baseUrl The base url to use for relative requests. */ public TestBrowser(WebDriver webDriver, String baseUrl) { super(webDriver); withDefaultUrl(baseUrl); }
/** * Quits and releases the {@link WebDriver} */ void quit() { if (getDriver() != null) { getDriver().quit(); } releaseFluent(); } }
/** * A test browser (Using Selenium WebDriver) with the FluentLenium API (https://github.com/Fluentlenium/FluentLenium). * * @param webDriver The WebDriver instance to use. * @param baseUrl The base url to use for relative requests. */ public TestBrowser(WebDriver webDriver, String baseUrl) { super(webDriver); withDefaultUrl(baseUrl); }
/** * Repeatedly applies this instance's input value to the given function until one of the following occurs: * * <ul> * <li> the function returns neither null nor false,</li> * <li> the function throws an unignored exception,</li> * <li> the default timeout expires</li> * </ul> * * useful in situations where FluentAdapter#await is too specific * (for example to check against page source or title) * * @param f function to execute * @param <T> the return type * @return the return value. */ public <T>T waitUntil(Function<WebDriver, T> f) { FluentWait<WebDriver> wait = fluentWait().withTimeout(Duration.ofMillis(3000)); return waitUntil(wait,f); }
/** * Creates a Test Browser. */ public static TestBrowser testBrowser(WebDriver of, int port) { return new TestBrowser(of, "http://localhost:" + port); }
@After public void quitBrowser() { if (browser != null) { browser.quit(); browser = null; } } }
/** * Repeatedly applies this instance's input value to the given function until one of the following occurs: * * <ul> * <li> the function returns neither null nor false,</li> * <li> the function throws an unignored exception,</li> * <li> the default timeout expires</li> * </ul> * * useful in situations where FluentAdapter#await is too specific * (for example to check against page source or title) * * @param f function to execute * @param <T> the return type * @return the return value. */ public <T>T waitUntil(Function<WebDriver, T> f) { FluentWait<WebDriver> wait = fluentWait().withTimeout(Duration.ofMillis(3000)); return waitUntil(wait,f); }
/** * Creates a Test Browser. * * @param of the web driver to run the browser with. * @param port the port to run against http://localhost * @return the test browser. */ public static TestBrowser testBrowser(WebDriver of, int port) { return new TestBrowser(of, "http://localhost:" + port); }
@After public void quitBrowser() { if (browser != null) { browser.quit(); browser = null; } } }
/** * Repeatedly applies this instance's input value to the given function until one of the following occurs: * the function returns neither null nor false, * the function throws an unignored exception, * the default timeout expires * * useful in situations where FluentAdapter#await is too specific * (for example to check against page source or title) * * @param f function to execute */ public <T>T waitUntil(Function<WebDriver, T> f) { FluentWait<WebDriver> wait = fluentWait().withTimeout(3000, TimeUnit.MILLISECONDS); return waitUntil(wait,f); }
/** * Creates a Test Browser. */ public static TestBrowser testBrowser(Class<? extends WebDriver> webDriver, int port) { try { return new TestBrowser(webDriver, "http://localhost:" + port); } catch(RuntimeException e) { throw e; } catch(Throwable t) { throw new RuntimeException(t); } }
/** * Executes a block of code in a running server, with a test browser. */ public static void running(TestServer server, WebDriver webDriver, final Callback<TestBrowser> block) { synchronized (PlayRunners$.MODULE$.mutex()) { TestBrowser browser = null; TestServer startedServer = null; try { start(server); startedServer = server; browser = testBrowser(webDriver); block.invoke(browser); } catch (Error e) { throw e; } catch (RuntimeException re) { throw re; } catch (Throwable t) { throw new RuntimeException(t); } finally { if (browser != null) { browser.quit(); } if (startedServer != null) { stop(startedServer); } } } }
/** * Creates a Test Browser. * * @param webDriver the class of webdriver. * @param port the local port to test against. * @return the test browser. */ public static TestBrowser testBrowser(Class<? extends WebDriver> webDriver, int port) { try { return new TestBrowser(webDriver, "http://localhost:" + port); } catch (RuntimeException e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } }
/** * Executes a block of code in a running server, with a test browser. * * @param server the test server. * @param webDriver the web driver instance. * @param block the block of code to execute. */ public static void running(TestServer server, WebDriver webDriver, final Consumer<TestBrowser> block) { Helpers$.MODULE$.runSynchronized(server.application(), asScala(() -> { TestBrowser browser = null; TestServer startedServer = null; try { start(server); startedServer = server; browser = testBrowser(webDriver, (Integer) OptionConverters.toJava(server.config().port()).get()); block.accept(browser); } finally { if (browser != null) { browser.quit(); } if (startedServer != null) { stop(startedServer); } } return null; })); }
/** * Creates a Test Browser. * * @param webDriver the class of webdriver. * @param port the local port to test against. * @return the test browser. */ public static TestBrowser testBrowser(Class<? extends WebDriver> webDriver, int port) { try { return new TestBrowser(webDriver, "http://localhost:" + port); } catch (RuntimeException e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } }