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:com.seleniumtests.ut.browserfactory.TestBrowserInfo.java

License:Apache License

/**
 * Check we filter drivers by OS/*from  w ww.j a v a2 s .c  o m*/
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testGetDriverFilesWithInstalledArtifactForOtherOS() throws Exception {
    PowerMockito.mockStatic(OSUtility.class);
    when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.LINUX);

    String[] driversFiles = new String[] { "windows/chromedriver_2.20_chrome-55-57_android-6.0.exe",
            "windows/chromedriver_2.29_chrome-56-58_android-7.0.exe",
            "windows/chromedriver_2.31_chrome-58-60.exe" };

    BrowserInfo bInfo = PowerMockito.spy(new BrowserInfo(BrowserType.CHROME, "55.0", null));
    PowerMockito.when(bInfo, "getDriverListFromJarResources", "driver-list-linux.txt").thenReturn(driversFiles);

    Assert.assertEquals(bInfo.getDriverFiles().size(), 0);
}

From source file:com.seleniumtests.util.osutility.OSUtility.java

License:Apache License

/******************************************
 *********** OS information ***************
 ******************************************/

public static Platform getCurrentPlatorm() {
    if (isWindows()) {
        return Platform.WINDOWS;
    } else if (isLinux()) {
        return Platform.LINUX;
    } else if (isMac()) {
        return Platform.MAC;
    } else {/* ww  w.  ja  v a 2 s.c o  m*/
        throw new ConfigurationException(getOSName() + " is not recognized as a valid platform");
    }
}

From source file:com.sios.stc.coseng.util.Run.java

License:Open Source License

public synchronized WebDriver getWebDriver(final String testName) throws MalformedURLException {

    WebDriver driver = null;//from ww w. ja v  a 2s.c  o m

    if (testName != null) {

        for (final TestParam p : param.testParam) {
            if (p.getTestName().equals(testName)) {

                // DesiredCapabilities
                // https://code.google.com/p/selenium/wiki/DesiredCapabilities

                // !! It is *not* necessary to start *any* of the browser driver
                // profiles to start 'private/icognito' as each new driver
                // instance starts with a *fresh* profile that does not persist
                // after the driver is quit. !!

                if (p.getBrowser().equals(Browser.FIREFOX)) {
                    final FirefoxProfile profile = new FirefoxProfile();
                    final DesiredCapabilities dc = DesiredCapabilities.firefox();
                    if (p.getPlatform().equals(Platform.LINUX)) {
                        // Explicitly enable native events(this is mandatory on Linux system,
                        // since they are not enabled by default.
                        profile.setEnableNativeEvents(true);
                        dc.setPlatform(p.getPlatform());
                        dc.setCapability(Common.BROWSER_CAPABILITY_FIREFOX_PROFILE, profile);
                    }
                    if (p.getSpot().equals(Spot.LOCAL)) {
                        driver = new FirefoxDriver(profile);
                    } else {
                        driver = new RemoteWebDriver(new URL(p.getSeleniumGridUrl()), dc);
                    }
                } else if (p.getBrowser().equals(Browser.CHROME)) {
                    final DesiredCapabilities dc = DesiredCapabilities.chrome();
                    dc.setPlatform(p.getPlatform());
                    if (p.getSpot().equals(Spot.LOCAL)) {
                        driver = new ChromeDriver();
                    } else {
                        driver = new RemoteWebDriver(new URL(p.getSeleniumGridUrl()), dc);
                    }
                } else if (p.getBrowser().toString().toLowerCase().startsWith("ie")) {
                    final DesiredCapabilities dc = DesiredCapabilities.internetExplorer();
                    dc.setBrowserName(Common.BROWSER_NAME_INTERNET_EXPLORER);
                    dc.setPlatform(p.getPlatform());
                    // IE8 and newer; Make sure
                    // HKEY_USERS\.Default\Software\Microsoft\Internet
                    // Explorer has DWORD TabProcGrowth set 0
                    // Launch separate process in 'private' mode.
                    dc.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
                    dc.setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");
                    //dc.setCapability(InternetExplorerDriver.LOG_FILE,
                    //        "C:/iedriver.log");
                    //dc.setCapability(InternetExplorerDriver.LOG_LEVEL,
                    //        "DEBUG");
                    dc.setCapability(InternetExplorerDriver.NATIVE_EVENTS, true);
                    // dc.setCapability(
                    // InternetExplorerDriver.REQUIRE_WINDOW_FOCUS,
                    // true);

                    // If *is* a specific IE9, IE10, IE11 (not IE) set the version
                    if (!p.getBrowser().equals(Browser.IE)) {
                        dc.setVersion(p.getBrowser().getVersion());
                    }

                    if (p.getSpot().equals(Spot.LOCAL)) {
                        driver = new InternetExplorerDriver();
                    } else {
                        driver = new RemoteWebDriver(new URL(p.getSeleniumGridUrl()), dc);
                    }
                }
            }
            // Collect the driver for quit after tests complete
            if (driver != null) {
                collectDriver(driver);
            }
        }
    }
    return driver;
}

From source file:com.vaadin.tests.elements.VaadinBrowserFactory.java

License:Apache License

@Override
public DesiredCapabilities create(Browser browser, String version, Platform platform) {
    final String PHANTOMJS_PATH_PROPERTY = "phantomjs.binary.path";
    final String PHANTOMJS_PATH_VALUE = "/usr/bin/phantomjs2";
    if (browser == Browser.PHANTOMJS) {
        DesiredCapabilities phantom2 = super.create(browser, "2", Platform.LINUX);
        // Hack for the test cluster
        phantom2.setCapability(PHANTOMJS_PATH_PROPERTY, PHANTOMJS_PATH_VALUE);
        return phantom2;
    }//from w  ww  .j  a  v  a2s .  c  o m

    DesiredCapabilities desiredCapabilities = super.create(browser, version, platform);

    if (platform == Platform.ANY && defaultBrowserPlatform.containsKey(browser)) {
        desiredCapabilities.setPlatform(defaultBrowserPlatform.get(browser));
    }

    if ("".equals(version) && defaultBrowserVersion.containsKey(browser)) {
        desiredCapabilities.setVersion(defaultBrowserVersion.get(browser));
    }
    if (browser.equals(Browser.FIREFOX)) {
        desiredCapabilities.setCapability(FirefoxDriver.MARIONETTE, false);
    }
    return desiredCapabilities;
}

From source file:fr.lip6.segmentations.SeleniumWrapper.java

protected 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 {/*from  w  ww.j a  va  2  s.c o  m*/
        throw new RuntimeException("Browser " + browser + " not recognized.");
    }

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

From source file:minium.web.config.WebDriverConfigurationTest.java

License:Apache License

@Test
public void testWebElementsDriverProperties() throws MalformedURLException {
    DesiredCapabilities expectedDesiredCapabilities = new DesiredCapabilities(BrowserType.CHROME, "39.0",
            Platform.LINUX);
    DesiredCapabilities expectedRequiredCapabilities = new DesiredCapabilities(
            ImmutableMap.of(CapabilityType.PLATFORM, Platform.LINUX.name()));
    assertThat(new DesiredCapabilities(webDriverProperties.getDesiredCapabilities()),
            equalTo(expectedDesiredCapabilities));
    assertThat(new DesiredCapabilities(webDriverProperties.getRequiredCapabilities()),
            equalTo(expectedRequiredCapabilities));
    assertThat(webDriverProperties.getUrl(), equalTo(new URL("http://localhost:4444/wd/hub")));
    assertThat(webDriverProperties.getWindow().getSize(), equalTo(new DimensionProperties(1280, 1024)));
    assertThat(webDriverProperties.getWindow().getPosition(), nullValue());
}

From source file:org.cerberus.serviceEngine.impl.SeleniumService.java

License:Open Source License

public DesiredCapabilities setCapabilityPlatform(DesiredCapabilities capabilities, String platform)
        throws CerberusException {
    if (platform.equalsIgnoreCase("WINDOWS")) {
        capabilities.setPlatform(Platform.WINDOWS);
    } else if (platform.equalsIgnoreCase("LINUX")) {
        capabilities.setPlatform(Platform.LINUX);
    } else if (platform.equalsIgnoreCase("ANDROID")) {
        capabilities.setPlatform(Platform.ANDROID);
    } else if (platform.equalsIgnoreCase("MAC")) {
        capabilities.setPlatform(Platform.MAC);
    } else if (platform.equalsIgnoreCase("UNIX")) {
        capabilities.setPlatform(Platform.UNIX);
    } else if (platform.equalsIgnoreCase("VISTA")) {
        capabilities.setPlatform(Platform.VISTA);
    } else if (platform.equalsIgnoreCase("WIN8")) {
        capabilities.setPlatform(Platform.WIN8);
    } else if (platform.equalsIgnoreCase("XP")) {
        capabilities.setPlatform(Platform.XP);
    } else {//from w w w  .  j a v  a2 s .com
        capabilities.setPlatform(Platform.ANY);
    }

    return capabilities;
}

From source file:org.emonocot.portal.driver.WebDriverFacade.java

License:Open Source License

/**
 *
 * @return the webdriver/*  w  ww. j  a v a2s .c  om*/
 * @throws IOException if there is a problem loading the
 *                     properties file
 */
private WebDriver createWebDriver() throws IOException {
    Resource propertiesFile = new ClassPathResource("META-INF/spring/application.properties");
    Properties properties = new Properties();
    properties.load(propertiesFile.getInputStream());
    String webdriverMode = properties.getProperty("selenium.webdriver.mode", "local");
    String driverName = properties.getProperty("selenium.webdriver.impl",
            "org.openqa.selenium.firefox.FirefoxDriver");
    WebDriverBrowserType browser = WebDriverBrowserType.fromString(driverName);
    String display = properties.getProperty("selenium.display.port", ":0");
    if (webdriverMode.equals("local")) {
        switch (browser) {
        case CHROME:
            String chromeLocation = properties.getProperty("selenium.webdriver.chromedriver.location");
            Map<String, String> environment = new HashMap<String, String>();
            environment.put("DISPLAY", display);
            ChromeDriverService chromeService = new ChromeDriverService.Builder()
                    .usingDriverExecutable(new File(chromeLocation)).usingAnyFreePort()
                    .withEnvironment(environment).build();
            chromeService.start();
            return new RemoteWebDriver(chromeService.getUrl(), DesiredCapabilities.chrome());
        case SAFARI:
            return new SafariDriver();
        case INTERNET_EXPLORER:
            String internetExplorerLocation = properties.getProperty("selenium.webdriver.ie.location");
            InternetExplorerDriverService ieService = InternetExplorerDriverService.createDefaultService();
            ieService.start();
            return new RemoteWebDriver(ieService.getUrl(), DesiredCapabilities.internetExplorer());
        case FIREFOX:
        default:
            FirefoxBinary firefoxBinary = new FirefoxBinary();
            firefoxBinary.setEnvironmentProperty("DISPLAY", display);
            ProfilesIni allProfiles = new ProfilesIni();
            FirefoxProfile profile = allProfiles.getProfile("default");
            return new FirefoxDriver(firefoxBinary, profile);
        }
    } else {

        DesiredCapabilities capabilities = new DesiredCapabilities();
        switch (browser) {
        case CHROME:
            capabilities = DesiredCapabilities.chrome();
            break;
        case INTERNET_EXPLORER:
            capabilities = DesiredCapabilities.internetExplorer();
            break;
        case SAFARI:
            capabilities = DesiredCapabilities.safari();
            break;
        case FIREFOX:
        default:
            capabilities = DesiredCapabilities.firefox();
        }
        String platformName = properties.getProperty("selenium.webdriver.platformName", "LINUX");
        WebDriverPlatformType platform = WebDriverPlatformType.valueOf(platformName);
        switch (platform) {
        case MAC:
            capabilities.setPlatform(Platform.MAC);
            break;
        case WINDOWS:
            capabilities.setPlatform(Platform.WINDOWS);
            break;
        case LINUX:
        default:
            capabilities.setPlatform(Platform.LINUX);
        }
        return new RemoteWebDriver(new URL("http://build.e-monocot.org:4444/wd/hub"), capabilities);
    }
}

From source file:org.jitsi.meet.test.pageobjects.base.TestHint.java

License:Apache License

/**
 * On Android the {@link TestHint}'s key is defined in
 * the react-native's 'accessibilityLabel', but on iOS the react-native's
 * 'testID' attribute is used. That's because 'testID' does not work as
 * expected on Android and the 'accessibilityLabel' works in a different way
 * on iOS than on Android.../*from  w w  w  .jav  a2  s.  c  o m*/
 *
 * @return {@code true} if {@link TestHint} should be located by
 * the accessibility id or {@code false} if the id based search should be
 * used.
 */
private boolean useAccessibilityForId() {
    Platform driversPlatform = driver.getCapabilities().getPlatform();

    // FIXME This looks like a bug, but I don't want to deal with this right
    // now.
    // Not sure if it's only when running appium from source or does it
    // sometimes report Android as LINUX platform. Also iOS is translated to
    // MAC ???
    return driversPlatform.is(Platform.ANDROID) || driversPlatform.is(Platform.LINUX);
}

From source file:org.kurento.test.compatibility.webrtc.WebRtcCompatibilityPlaybackTest.java

License:Open Source License

@Parameters(name = "{index}: {0}")
public static Collection<Object[]> data() {
    // Test: Browsers in saucelabs
    TestScenario test1 = new TestScenario();
    test1.addBrowser(BrowserConfig.BROWSER,
            new BrowserClient.Builder().client(Client.WEBRTC).browserType(BrowserType.CHROME)
                    .scope(BrowserScope.SAUCELABS).platform(Platform.WIN8_1).browserVersion("39").build());

    TestScenario test2 = new TestScenario();
    test2.addBrowser(BrowserConfig.BROWSER,
            new BrowserClient.Builder().client(Client.WEBRTC).browserType(BrowserType.FIREFOX)
                    .scope(BrowserScope.SAUCELABS).platform(Platform.LINUX).browserVersion("35").build());

    return Arrays.asList(new Object[][] { { test1 }, { test2 } });
}