Search in sources :

Example 81 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project selenium_java by sergueik.

the class TestBase method setUp.

@BeforeMethod
public void setUp() throws MalformedURLException {
    threadDriver = new ThreadLocal<RemoteWebDriver>();
    String browserName = "firefox";
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("platform", Platform.ANY.toString());
    capabilities.setCapability("browser", browserName);
    capabilities.setBrowserName(browserName);
    RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
    threadDriver.set(driver);
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) URL(java.net.URL) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 82 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project selenium_java by sergueik.

the class App method setUp.

@Before
public void setUp() throws Exception {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("platform", platform);
    capabilities.setCapability("browser", browserName);
    capabilities.setBrowserName(browserName);
    capabilities.setCapability("browserVersion", browserVersion);
    // org.openqa.selenium.WebDriverException: The best matching driver provider oenqa.selenium.chrome.ChromeDriver can't create a new driver instance for Caities [{platform=ANY, browserVersion=45, browser=firefox}]
    driver = new RemoteWebDriver(new URL(hubUrl), capabilities);
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) URL(java.net.URL) Before(org.junit.Before)

Example 83 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project ephemerals by LivePersonInc.

the class SeleniumParallelEphemeralTest method test.

@Test
public void test() throws Exception {
    // Define fixed thread pool with SIZE=10
    ExecutorService executor = Executors.newFixedThreadPool(10);
    // Submit Ephemeral deployment tasks to cluster using thread pool
    List<Future<RemoteWebDriver>> remoteWebDriverFutureList = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        Future<RemoteWebDriver> future = executor.submit(callableTask);
        remoteWebDriverFutureList.add(future);
    }
    // Get result of all tasks
    for (Future<RemoteWebDriver> future : remoteWebDriverFutureList) {
        RemoteWebDriver remoteWebDriver = future.get();
        remoteWebDriver.get("http://yahoo.com");
        Assert.assertNotNull(remoteWebDriver.findElementById("uh-logo"));
        remoteWebDriver.quit();
    }
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) ExecutorService(java.util.concurrent.ExecutorService) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) Test(org.junit.Test)

Example 84 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project ephemerals by LivePersonInc.

the class SeleniumWithNginxTest method test.

@Test
public void test() throws IOException {
    URL url = nginxResource.getEphemeral().get();
    RemoteWebDriver browser = seleniumResource.get();
    browser.get(url.toString() + "/index.html");
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) URL(java.net.URL) Test(org.junit.Test)

Example 85 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project webmagic by code4craft.

the class WebDriverPool method configure.

/**
 * Configure the GhostDriver, and initialize a WebDriver instance. This part
 * of code comes from GhostDriver.
 * https://github.com/detro/ghostdriver/tree/master/test/java/src/test/java/ghostdriver
 *
 * @author bob.li.0718@gmail.com
 * @throws IOException
 */
public void configure() throws IOException {
    // Read config file
    sConfig = new Properties();
    String configFile = DEFAULT_CONFIG_FILE;
    if (System.getProperty("selenuim_config") != null) {
        configFile = System.getProperty("selenuim_config");
    }
    sConfig.load(new FileReader(configFile));
    // Prepare capabilities
    sCaps = new DesiredCapabilities();
    sCaps.setJavascriptEnabled(true);
    sCaps.setCapability("takesScreenshot", false);
    String driver = sConfig.getProperty("driver", DRIVER_PHANTOMJS);
    // Fetch PhantomJS-specific configuration parameters
    if (driver.equals(DRIVER_PHANTOMJS)) {
        // "phantomjs_exec_path"
        if (sConfig.getProperty("phantomjs_exec_path") != null) {
            sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, sConfig.getProperty("phantomjs_exec_path"));
        } else {
            throw new IOException(String.format("Property '%s' not set!", PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY));
        }
        // "phantomjs_driver_path"
        if (sConfig.getProperty("phantomjs_driver_path") != null) {
            System.out.println("Test will use an external GhostDriver");
            sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY, sConfig.getProperty("phantomjs_driver_path"));
        } else {
            System.out.println("Test will use PhantomJS internal GhostDriver");
        }
    }
    // Disable "web-security", enable all possible "ssl-protocols" and
    // "ignore-ssl-errors" for PhantomJSDriver
    // sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new
    // String[] {
    // "--web-security=false",
    // "--ssl-protocol=any",
    // "--ignore-ssl-errors=true"
    // });
    ArrayList<String> cliArgsCap = new ArrayList<String>();
    cliArgsCap.add("--web-security=false");
    cliArgsCap.add("--ssl-protocol=any");
    cliArgsCap.add("--ignore-ssl-errors=true");
    sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
    // Control LogLevel for GhostDriver, via CLI arguments
    sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_CLI_ARGS, new String[] { "--logLevel=" + (sConfig.getProperty("phantomjs_driver_loglevel") != null ? sConfig.getProperty("phantomjs_driver_loglevel") : "INFO") });
    // 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) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ArrayList(java.util.ArrayList) FileReader(java.io.FileReader) IOException(java.io.IOException) Properties(java.util.Properties) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) 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