Search in sources :

Example 26 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project testcontainers-java by testcontainers.

the class LocalServerWebDriverContainerTest method testConnection.

@Test
public void testConnection() throws InterruptedException {
    RemoteWebDriver driver = chrome.getWebDriver();
    // Construct a URL that the browser container can access
    String hostIpAddress = chrome.getTestHostIpAddress();
    driver.get("http://" + hostIpAddress + ":" + localPort);
    String headingText = driver.findElement(By.cssSelector("h1")).getText().trim();
    assertEquals("The hardcoded success message was found on a page fetched from a local server", "It worked", headingText);
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver)

Example 27 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project testcontainers-java by testcontainers.

the class BaseWebDriverContainerTest method setupDriverFromRule.

@NotNull
private static RemoteWebDriver setupDriverFromRule(BrowserWebDriverContainer rule) {
    RemoteWebDriver driver = rule.getWebDriver();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    return driver;
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) NotNull(org.jetbrains.annotations.NotNull)

Example 28 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project testcontainers-java by testcontainers.

the class BrowserWebDriverContainer method containerIsStarted.

@Override
protected void containerIsStarted(InspectContainerResponse containerInfo) {
    driver = Unreliables.retryUntilSuccess(30, TimeUnit.SECONDS, Timeouts.getWithTimeout(10, TimeUnit.SECONDS, () -> () -> new RemoteWebDriver(getSeleniumAddress(), desiredCapabilities)));
    if (vncRecordingContainer != null) {
        LOGGER.debug("Starting VNC recording");
        vncRecordingContainer.start();
    }
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver)

Example 29 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project ghostdriver by detro.

the class BaseTest method prepareDriver.

@Before
public void prepareDriver() throws Exception {
    // Which driver to use? (default "phantomjs")
    String driver = sConfig.getProperty("driver", DRIVER_PHANTOMJS);
    // Start appropriate Driver
    if (isUrl(driver)) {
        sCaps.setBrowserName("phantomjs");
        mDriver = new RemoteWebDriver(new URL(driver), sCaps);
    } else if (driver.equals(DRIVER_FIREFOX)) {
        mDriver = new FirefoxDriver(sCaps);
    } else if (driver.equals(DRIVER_CHROME)) {
        mDriver = new ChromeDriver(sCaps);
    } else if (driver.equals(DRIVER_PHANTOMJS)) {
        mDriver = new PhantomJSDriver(sCaps);
    }
}
Also used : PhantomJSDriver(org.openqa.selenium.phantomjs.PhantomJSDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) URL(java.net.URL) Before(org.junit.Before)

Example 30 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project java.webdriver by sayems.

the class BrowserThreads method instantiateWebDriver.

private void instantiateWebDriver(DesiredCapabilities desiredCapabilities) {
    log.info(" ");
    log.info("Current Operating System: " + operatingSystem);
    log.info("Current Architecture: " + systemArchitecture);
    log.info("Current Browser Selection: " + selectedDriverType);
    log.info(" ");
    if (useRemoteWebDriver) {
        URL seleniumGridURL = null;
        try {
            seleniumGridURL = new URL(System.getProperty("gridURL"));
        } catch (MalformedURLException e) {
            log.error("Either no legal protocol could be found or the string could not be parsed.", e);
        }
        String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");
        if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
            desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
        }
        if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
            desiredCapabilities.setVersion(desiredBrowserVersion);
        }
        webdriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
    } else {
        webdriver = selectedDriverType.browser.getWebDriverObject(desiredCapabilities);
    }
    webdriver.manage().window().setSize(new Dimension(1280, 1024));
    setup();
}
Also used : MalformedURLException(java.net.MalformedURLException) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) Dimension(org.openqa.selenium.Dimension) URL(java.net.URL)

Aggregations

RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)101 URL (java.net.URL)39 Test (org.junit.Test)36 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)29 File (java.io.File)16 WebDriver (org.openqa.selenium.WebDriver)14 MalformedURLException (java.net.MalformedURLException)13 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)13 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)12 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)12 IOException (java.io.IOException)11 Dimension (org.openqa.selenium.Dimension)9 InternetExplorerDriver (org.openqa.selenium.ie.InternetExplorerDriver)7 PhantomJSDriver (org.openqa.selenium.phantomjs.PhantomJSDriver)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)6 EventFiringWebDriver (org.openqa.selenium.support.events.EventFiringWebDriver)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Before (org.junit.Before)5