Example usage for org.openqa.selenium Platform getCurrent

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

Introduction

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

Prototype

public static Platform getCurrent() 

Source Link

Document

Get current platform (not necessarily the same as operating system).

Usage

From source file:com.mengge.service.local.AppiumServiceBuilder.java

License:Apache License

@SuppressWarnings("unchecked")
private String parseCapabilities() {
    if (Platform.getCurrent().is(Platform.WINDOWS)) {
        return parseCapabilitiesIfWindows();
    }/*from  w  w w.  jav  a2 s . c om*/
    return parseCapabilitiesIfUNIX();
}

From source file:com.opera.core.systems.OperaDriverTest.java

License:Apache License

@Test
@Ignore(products = CORE, value = "core does not support -pd")
public void testSetProfile() throws Exception {
    if (!Platform.getCurrent().is(Platform.LINUX)) {
        return;/*from   ww w .  j a  v  a2 s .co  m*/
    }

    FileHandler.delete(new File("/tmp/opera-test-profile/"));

    DesiredCapabilities c = new DesiredCapabilities();
    c.setCapability(OperaDriver.PROFILE, "/tmp/opera-test-profile/");

    TestOperaDriver a;
    try {
        a = new TestOperaDriver(c);
    } catch (Exception e) {
        // If immediately exited, then it doesn't support the flags
        if (e.getMessage().contains("Opera exited immediately")) {
            return;
        } else {
            throw e;
        }
    }

    String profile = a.preferences().get("User Prefs", "Opera Directory").toString();
    assertEquals("/tmp/opera-test-profile/", profile);
    a.quit();
}

From source file:com.opera.core.systems.OperaLauncherRunnerSettingsTest.java

License:Apache License

@BeforeClass
public static void beforeAll() {
    if (Platform.getCurrent().is(Platform.WINDOWS)) {
        fakeBinary = new File("C:\\WINDOWS\\system32\\find.exe");
    } else {/*from  w  w  w.  j  a  v a  2 s  .co  m*/
        fakeBinary = new File("/bin/echo");
    }
}

From source file:com.opera.core.systems.OperaLauncherRunnerTest.java

License:Apache License

@Test
public void testBadLauncher() throws Exception {
    File fakeLauncher;//from   www. j a v  a 2 s. c  o m
    // Programs that should be installed that have no side effects when run
    if (Platform.getCurrent().is(Platform.WINDOWS)) {
        fakeLauncher = new File("C:\\WINDOWS\\system32\\find.exe");
    } else {
        fakeLauncher = new File("/bin/echo");
    }

    assertTrue("Imposter launcher exists", fakeLauncher.exists());

    settings.setLauncher(fakeLauncher.getCanonicalFile());

    try {
        runner = new OperaLauncherRunner(settings);
        fail("Did not throw OperaRunnerException");
    } catch (OperaRunnerException e) {
        assertTrue("Throws timeout error", e.getMessage().toLowerCase().contains("timeout"));
    }
}

From source file:com.opera.core.systems.OperaRunnerSettingsTest.java

License:Apache License

@BeforeClass
public static void setUpBeforeClass() {
    initFixtures();//from   w ww  .  ja va2  s . c o m

    if (Platform.getCurrent().is(Platform.WINDOWS)) {
        fakeBinary = new File("C:\\WINDOWS\\system32\\find.exe");
    } else {
        fakeBinary = new File("/bin/echo");
    }
}

From source file:com.opera.core.systems.OperaRunnerSettingsTest.java

License:Apache License

@Test
public void testSetDisplay() {
    Integer display = 8;//  w w w . ja  v  a2 s  .c  o m
    Exception unsupportedOperationException = null;

    try {
        settings.setDisplay(display);
    } catch (UnsupportedOperationException e) {
        unsupportedOperationException = e;
    }

    if (Platform.getCurrent() == Platform.WINDOWS) {
        assertNotNull(unsupportedOperationException);
    } else if (Platform.getCurrent() == Platform.LINUX || Platform.getCurrent() == Platform.UNIX) {
        assertNull(unsupportedOperationException);
        assertEquals(display, settings.getDisplay());
    }
}

From source file:com.opera.core.systems.OperaRunnerSettingsTest.java

License:Apache License

@Test(expected = WebDriverException.class)
public void testSetProfileWithInvalidString() {
    if (Platform.getCurrent().is(Platform.WINDOWS)) {
        settings.setProfile(":/this/does/not/exist");
    } else {/* w  ww .j  ava2 s. co  m*/
        settings.setProfile("/this/does/not/exist");
    }
    runner = new TestOperaRunner(settings);
}

From source file:com.opera.core.systems.OperaSettings.java

License:Apache License

/**
 * Sets the X display to use.  Only works on GNU/Linux.  Typically this allows you to open Opera
 * in an X virtual framebuffer.//www. j  a  v a  2 s .  co  m
 *
 * @param display the X display to use
 * @throws UnsupportedOperationException if on a non-GNU/Linux operating system
 */
public void setDisplay(int display) {
    if (!Platform.getCurrent().is(LINUX)) {
        throw new UnsupportedOperationException("Unsupported platform: " + Platform.getCurrent());
    }

    options.get(DISPLAY).setValue(display);
}

From source file:com.opera.core.systems.OperaSettingsIntegrationTest.java

License:Apache License

@Test
public void launcherIsUsedWhenSet() throws IOException {
    tmp.create();/*from  ww  w . j ava2  s .  co m*/
    File newLauncher = tmp.newFile("newLauncher");
    Files.copy(OperaLauncherRunner.LAUNCHER_DEFAULT_LOCATION, newLauncher);
    if (!Platform.getCurrent().is(WINDOWS)) {
        newLauncher.setExecutable(true);
    }

    settings.setLauncher(newLauncher);
    TestDriver driver = new TestDriverBuilder().using(settings).get();

    assertNotNull(driver);
    assertEquals(newLauncher, driver.getSettings().getLauncher());

    driver.quit();
}

From source file:com.opera.core.systems.OperaSettingsTest.java

License:Apache License

@Test
public void displayCanBeSetOnLinuxOnly() {
    try {/*from   w  ww .ja  v  a  2  s  .  co  m*/
        settings.setDisplay(7);
        if (!Platform.getCurrent().is(LINUX)) {
            fail("Expected exception on setting the framebuffer display");
        }
    } catch (RuntimeException e) {
        if (!Platform.getCurrent().is(LINUX)) {
            assertThat(e, is(instanceOf(UnsupportedOperationException.class)));
        }
    }
}