Search in sources :

Example 1 with Platform

use of org.openqa.selenium.Platform in project zalenium by zalando.

the class ParallelIT method startWebDriverAndGetBaseUrl.

@BeforeMethod(alwaysRun = true)
public void startWebDriverAndGetBaseUrl(Method method, Object[] testArgs) throws MalformedURLException {
    String zaleniumUrl = String.format("http://%s:%s/wd/hub", ZALENIUM_HOST, ZALENIUM_PORT);
    String browserType = testArgs[0].toString();
    Platform platform = (Platform) testArgs[1];
    boolean localTesting = false;
    if (testArgs.length > 2) {
        localTesting = testArgs[2] != null && (boolean) testArgs[2];
    }
    LOGGER.info("STARTING {} on {} - {}, using {}", method.getName(), browserType, platform.name(), zaleniumUrl);
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setCapability(CapabilityType.BROWSER_NAME, browserType);
    desiredCapabilities.setCapability(CapabilityType.PLATFORM_NAME, platform);
    desiredCapabilities.setCapability("name", method.getName());
    if (localTesting) {
        desiredCapabilities.setCapability("tunnel", "true");
        desiredCapabilities.setCapability("browserstack.local", "true");
        desiredCapabilities.setCapability("browserstack.localIdentifier", "zalenium");
        desiredCapabilities.setCapability("tunnelIdentifier", "zalenium");
    }
    try {
        webDriver.set(new RemoteWebDriver(new URL(zaleniumUrl), desiredCapabilities));
    } catch (Exception e) {
        LOGGER.warn("FAILED {} on {} - {}", method.getName(), browserType, platform.name());
        throw e;
    }
}
Also used : Platform(org.openqa.selenium.Platform) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with Platform

use of org.openqa.selenium.Platform in project zalenium by zalando.

the class ParallelIT method quitBrowser.

@AfterMethod(alwaysRun = true)
public void quitBrowser(Method method, Object[] testArgs) {
    webDriver.get().quit();
    String browserType = testArgs[0].toString();
    Platform platform = (Platform) testArgs[1];
    LOGGER.info("FINISHING {} on {} - {}", method.getName(), browserType, platform.name());
}
Also used : Platform(org.openqa.selenium.Platform) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) AfterMethod(org.testng.annotations.AfterMethod)

Example 3 with Platform

use of org.openqa.selenium.Platform in project zalenium by zalando.

the class CloudProxyHtmlRenderer method getPlatform.

/**
 * return the platform for the proxy. It should be the same for all slots of the proxy, so checking that.
 * @param proxy remote proxy
 * @return Either the platform name, "Unknown", "mixed OS", or "not specified".
 */
private static String getPlatform(RemoteProxy proxy) {
    Platform res;
    if (proxy.getTestSlots().size() == 0) {
        return "Unknown";
    }
    res = getPlatform(proxy.getTestSlots().get(0));
    for (TestSlot slot : proxy.getTestSlots()) {
        Platform tmp = getPlatform(slot);
        if (!tmp.is(res)) {
            return "mixed OS";
        }
        res = tmp;
    }
    if (res == null) {
        return "not specified";
    }
    return res.toString();
}
Also used : Platform(org.openqa.selenium.Platform) TestSlot(org.openqa.grid.internal.TestSlot)

Aggregations

Platform (org.openqa.selenium.Platform)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 TestSlot (org.openqa.grid.internal.TestSlot)1 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)1 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)1 AfterMethod (org.testng.annotations.AfterMethod)1 BeforeMethod (org.testng.annotations.BeforeMethod)1