Example usage for org.openqa.selenium Platform LINUX

List of usage examples for org.openqa.selenium Platform LINUX

Introduction

In this page you can find the example usage for org.openqa.selenium Platform LINUX.

Prototype

Platform LINUX

To view the source code for org.openqa.selenium Platform LINUX.

Click Source Link

Usage

From source file:org.musetest.selenium.tests.BrowserCapabilitiesTest.java

License:Open Source License

@Test
void createCapabilities() throws IOException {
    ObjectMapper mapper = JsonMapperFactory.createMapper(new TypeLocator((MuseProject) null));
    SeleniumBrowserCapabilities sel_caps = mapper
            .readValue(getClass().getResourceAsStream("capabilities1.json"), SeleniumBrowserCapabilities.class);

    DesiredCapabilities capabilities = sel_caps.toDesiredCapabilities();

    Assertions.assertEquals(BrowserType.FIREFOX, capabilities.getBrowserName());
    Assertions.assertEquals(Platform.LINUX, capabilities.getPlatform());
    Assertions.assertEquals("7.1", capabilities.getVersion());
}

From source file:org.openqa.grid.common.RegistrationRequestTest.java

License:Apache License

@Test
public void json() {
    RegistrationRequest req = new RegistrationRequest();
    req.setId("id");
    req.setName("Franois");
    req.setDescription("a\nb\nc");

    String name = "%super !";
    String value = "% // \\";

    Map<String, Object> config = new HashMap<String, Object>();
    config.put(name, value);//from   w  w w  .  ja va2s . c  o m

    req.setConfiguration(config);

    for (int i = 0; i < 5; i++) {
        DesiredCapabilities cap = new DesiredCapabilities("firefox", "" + i, Platform.LINUX);
        req.addDesiredCapability(cap);
    }

    String json = req.toJSON();

    RegistrationRequest req2 = RegistrationRequest.getNewInstance(json);

    Assert.assertEquals(req2.getId(), req.getId());
    Assert.assertEquals(req2.getName(), req.getName());
    Assert.assertEquals(req2.getDescription(), req.getDescription());

    Assert.assertEquals(req2.getConfigAsString(name), req.getConfigAsString(name));
    Assert.assertEquals(req2.getCapabilities().size(), req.getCapabilities().size());

}

From source file:org.openqa.grid.internal.utils.DefaultCapabilityMatcherTest.java

License:Apache License

@Test
public void nullEmptyValues() {
    DefaultCapabilityMatcher matcher = new DefaultCapabilityMatcher();

    Map<String, Object> requested = new HashMap<String, Object>();
    requested.put(CapabilityType.BROWSER_NAME, "firefox");
    requested.put(CapabilityType.PLATFORM, null);
    requested.put(CapabilityType.VERSION, "");

    Map<String, Object> node = new HashMap<String, Object>();
    node.put(CapabilityType.BROWSER_NAME, "firefox");
    node.put(CapabilityType.PLATFORM, Platform.LINUX);
    node.put(CapabilityType.VERSION, "3.6");

    Assert.assertTrue(matcher.matches(node, requested));

}

From source file:org.qe4j.web.OpenWebDriver.java

License:Open Source License

/**
 * Constructs the property key to lookup the browser binary path.
 *
 * @param platform//from w  ww .j a  va2 s.c  o  m
 * @param browser
 * @param version
 * @return property key to lookup browser binary else null if the binary is
 *         not found or definition indicates it should use the default
 *         binary
 */
protected String getBrowserBinaryPath(Platform platform, Browser browser, String version,
        Properties properties) {
    // determine platform part of property key
    String platformKeyPart = null;
    if (platform.is(Platform.LINUX)) {
        platformKeyPart = "linux";
    } else if (platform.is(Platform.WINDOWS)) {
        platformKeyPart = "win";
    } else if (platform.is(Platform.MAC)) {
        platformKeyPart = "mac";
    } else {
        throw new IllegalArgumentException("platform " + platform + " not currently supported");
    }

    String browserBinaryPropertyKey = "webdriver." + platformKeyPart + "." + browser.toString().toLowerCase()
            + "." + version;
    log.info("looking up webdriver browser binary path property {}", browserBinaryPropertyKey);
    String browserBinary = properties.getProperty(browserBinaryPropertyKey);

    if (browserBinary != null) {
        if (browserBinary.equals("")) {
            browserBinary = null;
        } else {
            log.info("using browser binary {}", browserBinary);
        }
    }

    return browserBinary;
}

From source file:org.qe4j.web.OpenWebDriver.java

License:Open Source License

/**
 * Converts the property definition of the platform to the Selenium enum
 * representation of it. Throws exception if the platform is not supported
 * by SauceLabs (current remote execution environment).
 *
 * @param platformProperty//from   www.  j av  a  2 s . c  om
 * @return Selenium platform enum
 */
public static Platform lookupPlatform(String platformProperty) {
    String platform = platformProperty.toLowerCase();
    if (platform.equals("xp")) {
        return Platform.XP;
    } else if (platform.equals("vista")) {
        return Platform.VISTA;
    } else if (platform.equals("linux")) {
        return Platform.LINUX;
    } else if (platform.equals("windows")) {
        return Platform.WINDOWS;
    } else if (platform.equals("mac")) {
        return Platform.MAC;
    } else {
        throw new IllegalArgumentException(
                "platform property " + platformProperty + " is not currently supported for remote web driver");
    }
}

From source file:org.qe4j.web.OpenWebDriverTest.java

License:Open Source License

@Test
public void lookupPlatform() {
    Assert.assertEquals(OpenWebDriver.lookupPlatform("Xp"), Platform.XP, "xp platform");
    Assert.assertEquals(OpenWebDriver.lookupPlatform("VISTA"), Platform.VISTA, "vista/win7 platform");
    Assert.assertEquals(OpenWebDriver.lookupPlatform("linUX"), Platform.LINUX, "linux platform");
}

From source file:org.qe4j.web.OpenWebDriverTest.java

License:Open Source License

@Test
public void getBrowserBinaryPathDefinedNull() throws IOException {
    Properties properties = getProperties();
    properties.setProperty("webdriver.linux.chrome.24", "");
    OpenWebDriver driver = new OpenWebDriver();
    String binaryPath = driver.getBrowserBinaryPath(Platform.LINUX, Browser.CHROME, "24", properties);
    Assert.assertNull(binaryPath, "prop key exists but not defined");
}

From source file:pagelyzer.Capture.java

License:Open Source License

/**
 * Prepare a new instance of webdriver for browser
* This function is a adaptation from the setup() method from BrowserShot_mapred proyect
* @param browser the current browser to setup
**//*from   w w  w.ja  va  2 s . co m*/
public void setup(String browser) {
    System.out.println("Setting up browser: " + browser);
    DesiredCapabilities capability = null;
    if (browser.equals("firefox")) {
        capability = DesiredCapabilities.firefox();
    } else if (browser.equals("opera")) {
        capability = DesiredCapabilities.opera();
    } else if (browser.equals("chrome")) {
        capability = DesiredCapabilities.chrome();
        capability.setCapability("chrome.switches", Arrays.asList("--disable-logging"));
    } else {
        throw new RuntimeException("Browser " + browser + " not recognized.");
    }

    capability.setPlatform(Platform.LINUX);
    this.browser.desc = browser;
    this.browser.capabilities = capability;
    initWebDriver();
}

From source file:pt.fccn.saw.selenium.WebDriverTestBase.java

License:Open Source License

/**
 * Gets a suitable Platform object given a OS/Platform string..
 *
 * @param platformString The given string for the OS/Platform to use
 * @return The Platform object that represent the requested OS/Platform
 *//*w  ww.j a  va  2  s.  co  m*/
private static Platform selectPlatform(String platformString) {
    Platform platform = null;

    if (platformString.contains("Windows")) {
        if (platformString.contains("2008")) {
            platform = Platform.VISTA;
        } else {
            platform = Platform.XP;
        }
    } else if (platformString.toLowerCase().equals("linux")) {
        platform = Platform.LINUX;
    } else {
        System.err.println("Cannot find a suitable platform/OS for [" + platformString + "]");
    }
    return platform;
}

From source file:test.java.com.uttesh.selenium.Tests.BaseTest.java

public WebDriver getRemoteWebDriver(String platform, String browser, String version, String url) {
    try {//from   ww w .  j a v  a  2s  .  co  m
        DesiredCapabilities capability = new DesiredCapabilities();
        if (platform.equalsIgnoreCase("Windows")) {
            capability.setPlatform(Platform.WINDOWS);
        }
        if (platform.equalsIgnoreCase("Linux")) {
            capability.setPlatform(Platform.LINUX);
        }

        if (browser.equalsIgnoreCase("Internet Explorer")) {
            capability = DesiredCapabilities.internetExplorer();
        }
        if (browser.equalsIgnoreCase("Firefox")) {
            capability = DesiredCapabilities.firefox();
        }
        capability.setVersion(version);
        driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
        return driver;
    } catch (MalformedURLException ex) {
        Logger.getLogger(AmazonTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}