Search in sources :

Example 56 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project page-factory-2 by sbtqa.

the class TagWebDriver method createRemoteWebDriver.

private static WebDriver createRemoteWebDriver(String webDriverUrl, DesiredCapabilities capabilities) throws MalformedURLException {
    URL remoteUrl = new URL(webDriverUrl);
    capabilities.merge(new SelenoidCapabilitiesParser().parse());
    return new RemoteWebDriver(remoteUrl, capabilities);
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) SelenoidCapabilitiesParser(ru.sbtqa.tag.pagefactory.support.capabilities.SelenoidCapabilitiesParser) URL(java.net.URL)

Example 57 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project mamute by caelum.

the class AcceptanceTestBase method ghostDriver.

private static WebDriver ghostDriver() {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setJavascriptEnabled(true);
    capabilities.setCapability("takesScreenshot", true);
    try {
        return new RemoteWebDriver(new URL("http://localhost:8787/"), capabilities);
    } catch (MalformedURLException e) {
        throw new RuntimeException("could not build ghost driver", e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) URL(java.net.URL)

Example 58 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project jmeter-plugins by undera.

the class RemoteDriverConfigTest method shouldCreateRemoteDriver.

@Test
public void shouldCreateRemoteDriver() throws Exception {
    config.setSeleniumGridUrl("http://my.awesomegrid.com");
    RemoteWebDriver mockRemoteWebDriver = Mockito.mock(RemoteWebDriver.class);
    whenNew(RemoteWebDriver.class).withParameterTypes(URL.class, Capabilities.class).withArguments(isA(URL.class), isA(Capabilities.class)).thenReturn(mockRemoteWebDriver);
    final RemoteWebDriver browser = config.createBrowser();
    assertThat(browser, is(mockRemoteWebDriver));
    verifyNew(RemoteWebDriver.class, times(1)).withArguments(isA(URL.class), isA(Capabilities.class));
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) Capabilities(org.openqa.selenium.Capabilities) URL(java.net.URL) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 59 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project divolte-collector by divolte.

the class SeleniumTestBase method setupSauceLabs.

private void setupSauceLabs() throws MalformedURLException {
    final String sauceUserName = Optional.ofNullable(System.getenv(SAUCE_USER_NAME_ENV_VAR)).orElseThrow(() -> new RuntimeException("When using 'sauce' as Selenium driver, please set the SauceLabs username " + "in the " + SAUCE_USER_NAME_ENV_VAR + " env var."));
    final String sauceApiKey = Optional.ofNullable(System.getenv(SAUCE_API_KEY_ENV_VAR)).orElseThrow(() -> new RuntimeException("When using 'sauce' as Selenium driver, please set the SauceLabs username " + "in the " + SAUCE_API_KEY_ENV_VAR + " env var."));
    final String sauceHost = Optional.ofNullable(System.getenv(SAUCE_HOST_ENV_VAR)).orElse("localhost");
    final int saucePort = Optional.ofNullable(System.getenv(SAUCE_PORT_ENV_VAR)).map(Ints::tryParse).orElse(4445);
    final DesiredCapabilities caps = capabilities.get();
    // Note: getMethodName() is misleading. It's really the formatted name from the @Parameters annotation.
    caps.setCapability("name", String.format("%s: %s", getClass().getSimpleName(), testName.getMethodName()));
    caps.setCapability("public", "team");
    caps.setCapability("videoUploadOnPass", false);
    final RemoteWebDriver remoteDriver = new RemoteWebDriver(new URL(String.format("http://%s:%s@%s:%d/wd/hub", sauceUserName, sauceApiKey, sauceHost, saucePort)), caps);
    final String sauceJobId = remoteDriver.getSessionId().toString();
    final SauceREST sauce = new SauceREST(sauceUserName, sauceApiKey);
    driver = remoteDriver;
    testResultHook = Optional.of(result -> {
        switch(result) {
            case Passed:
                sauce.jobPassed(sauceJobId);
                break;
            case Skipped:
                sauce.deleteJob(sauceJobId);
                break;
            case Failed:
                sauce.jobFailed(sauceJobId);
        }
    });
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) Statement(org.junit.runners.model.Statement) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) java.util(java.util) URL(java.net.URL) WebDriver(org.openqa.selenium.WebDriver) WebDriverException(org.openqa.selenium.WebDriverException) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) LoggerFactory(org.slf4j.LoggerFactory) Supplier(java.util.function.Supplier) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) ImmutableList(com.google.common.collect.ImmutableList) Nullable(javax.annotation.Nullable) BrowserLists(io.divolte.server.BrowserLists) AssumptionViolatedException(org.junit.AssumptionViolatedException) PhantomJSDriver(org.openqa.selenium.phantomjs.PhantomJSDriver) SafariDriver(org.openqa.selenium.safari.SafariDriver) Logger(org.slf4j.Logger) MalformedURLException(java.net.MalformedURLException) Parameter(org.junit.runners.Parameterized.Parameter) Description(org.junit.runner.Description) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) Instant(java.time.Instant) Ints(com.google.common.primitives.Ints) SauceREST(com.saucelabs.saucerest.SauceREST) Collectors(java.util.stream.Collectors) TestServer(io.divolte.server.ServerTestUtils.TestServer) Consumer(java.util.function.Consumer) org.junit.rules(org.junit.rules) Rule(org.junit.Rule) Preconditions(com.google.common.base.Preconditions) Logs(org.openqa.selenium.logging.Logs) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) SauceREST(com.saucelabs.saucerest.SauceREST) URL(java.net.URL)

Example 60 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project divolte-collector by divolte.

the class SeleniumTestBase method setupBrowserStack.

private void setupBrowserStack() throws MalformedURLException {
    final String bsUserName = Optional.ofNullable(System.getenv(BS_USER_NAME_ENV_VAR)).orElseThrow(() -> new RuntimeException("When using 'browserstack' as Selenium driver, please set the BrowserStack username " + "in the " + BS_USER_NAME_ENV_VAR + " env var."));
    final String bsApiKey = Optional.ofNullable(System.getenv(BS_API_KEY_ENV_VAR)).orElseThrow(() -> new RuntimeException("When using 'browserstack' as Selenium driver, please set the BrowserStack username " + "in the " + BS_API_KEY_ENV_VAR + " env var."));
    final DesiredCapabilities caps = capabilities.get();
    // Note: getMethodName() is misleading. It's really the formatted name from the @Parameters annotation.
    caps.setCapability("job-name", String.format("%s: %s", getClass().getSimpleName(), testName.getMethodName()));
    driver = new RemoteWebDriver(new URL(String.format("http://%s:%s@hub.browserstack.com/wd/hub", bsUserName, bsApiKey)), caps);
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) 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