Package org.openqa.selenium

Examples of org.openqa.selenium.WebDriver


     *
     * @return the context of WebDriver for current thread
     * @throws NullPointerException when context is null
     */
    static WebDriver get() {
        WebDriver driver = REFERENCE.get();
        if (driver == null) {
            throw new NullPointerException("context is null - it needs to be setup before starting to use it");
        }
        return driver;
    }
View Full Code Here


    @Inject
    private Instance<ServiceLoader> serviceLoader;

    @Override
    public void enrich(Object o) {
        final WebDriver driver = GrapheneContext.getProxy();
        for (SearchContextTestEnricher enricher: serviceLoader.get().all(SearchContextTestEnricher.class)) {
            enricher.enrich(driver, o);
        }
    }
View Full Code Here

        assertThat(scriptable.getLog(), is(logger));
    }

    @Test
    public void shouldAssignBrowser() {
        final WebDriver browser = Mockito.mock(WebDriver.class);
        scriptable.setBrowser(browser);
        assertThat(scriptable.getBrowser(), is(browser));
    }
View Full Code Here

        verify(proxyFactory, times(1)).getConfigUrlProxy(Mockito.isA(String.class));
    }

    @Test
    public void shouldSetBrowserForCurrentThread() {
        WebDriver browser = mock(WebDriver.class);

        config.setThreadBrowser(browser);

        assertThat((Collection<WebDriver>)config.getThreadBrowsers().values(), hasSize(1));
        assertThat((Collection<WebDriver>) config.getThreadBrowsers().values(), hasItem(browser));
View Full Code Here

        assertThat((Collection<WebDriver>) config.getThreadBrowsers().values(), hasItem(browser));
    }

    @Test
    public void shouldNotSetNullBrowserForCurrentThread() {
        WebDriver browser = mock(WebDriver.class);

        config.setThreadBrowser(browser);
        assertThat((Collection<WebDriver>) config.getThreadBrowsers().values(), hasSize(1));
        assertThat((Collection<WebDriver>) config.getThreadBrowsers().values(), hasItem(browser));
View Full Code Here

        assertThat((Collection<WebDriver>) config.getThreadBrowsers().values(), hasItem(browser));
    }

    @Test
    public void shouldOnlyHaveOneBrowserForCurrentThread() {
        WebDriver firstBrowser = mock(WebDriver.class);
        WebDriver secondBrowser = mock(WebDriver.class);

        config.setThreadBrowser(firstBrowser);
        config.setThreadBrowser(secondBrowser);

        assertThat((Collection<WebDriver>)config.getThreadBrowsers().values(), hasSize(1));
View Full Code Here

    }

    @Test
    public void shouldBeAbleToAddMultipleBrowsersForEachThread() throws InterruptedException {
        // mock the browsers that will be created per thread
        final WebDriver firstBrowser = mock(WebDriver.class);
        final WebDriver secondBrowser = mock(WebDriver.class);

        Thread firstThread = new Thread() {
            public void run() {
                config.setThreadBrowser(firstBrowser);
            }
View Full Code Here

        assertThat((Collection<WebDriver>)config.getThreadBrowsers().values(), hasItem(secondBrowser));
    }

    @Test
    public void shouldHaveBrowserForCurrentThread() {
        WebDriver browser = mock(WebDriver.class);

        config.setThreadBrowser(browser);

        assertThat(config.hasThreadBrowser(), is(true));
    }
View Full Code Here

        assertThat(config.hasThreadBrowser(), is(false));
    }

    @Test
    public void shouldRemoveBrowserFromCurrentThread() {
        WebDriver browser = mock(WebDriver.class);
        config.setThreadBrowser(browser);

        final WebDriver removed = config.removeThreadBrowser();

        assertThat((Map<String, WebDriver>)config.getThreadBrowsers(), is(Collections.<String, WebDriver>emptyMap()));
        assertThat(browser, is(removed));
    }
View Full Code Here

        assertThat(browser, is(removed));
    }

    @Test
    public void shouldRemoveBrowserFromCurrentThreadEvenIfNoBrowserPresent() {
        final WebDriver removed = config.removeThreadBrowser();

        assertThat((Map<String, WebDriver>)config.getThreadBrowsers(), is(Collections.<String, WebDriver>emptyMap()));
        assertThat(removed, is(nullValue()));
    }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.WebDriver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.