Example usage for org.openqa.selenium Platform WINDOWS

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

Introduction

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

Prototype

Platform WINDOWS

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

Click Source Link

Document

Never returned, but can be used to request a browser running on any version of Windows.

Usage

From source file:com.htmlhifive.pitalium.it.exec.param.FileParameterTest.java

License:Apache License

/**
 * ???????<br>/*from  w  ww  . jav a 2 s.c o  m*/
 * com.htmlhifive.test.it.exec.param???.<br>
 * FireFox<br>
 * ??????????.<br>
 * ?????????????????.
 */
@Test
public void checkConfig() {
    driver.get(null);

    PtlTestConfig config = PtlTestConfig.getInstance();

    // ???
    EnvironmentConfig env = config.getEnvironment();
    TestAppConfig appConfig = config.getTestAppConfig();
    assertEquals(ExecMode.RUN_TEST, env.getExecMode()); //

    // hub???
    String EXPECTED_HUB_HOST = "localhost";
    int EXPECTED_HUB_POST = 4444;

    assertEquals(EXPECTED_HUB_HOST, env.getHubHost());
    assertEquals(EXPECTED_HUB_POST, env.getHubPort());

    // ?hub???
    URL server = ((HttpCommandExecutor) driver.getCommandExecutor()).getAddressOfRemoteServer();
    assertEquals(EXPECTED_HUB_HOST, server.getHost());
    assertEquals(EXPECTED_HUB_POST, server.getPort());

    // capability???
    PtlCapabilities cap = driver.getCapabilities();
    assertEquals("com\\htmlhifive\\pitalium\\it\\exec\\param\\capabilities_FileParameterTest.json",
            env.getCapabilitiesFilePath());
    assertEquals(Platform.WINDOWS, cap.getPlatform());
    assertEquals("WINDOWS", cap.getCapability("os"));
    assertEquals("firefox", cap.getBrowserName());

    // ?UA????
    String userAgent = (String) driver.executeScript("return navigator.userAgent");
    assertTrue(userAgent.contains("Windows"));
    assertTrue(userAgent.contains("Firefox"));

    // driver?
    assertEquals(WebDriverSessionLevel.TEST_CLASS, env.getWebDriverSessionLevel());
    checkConfigTestDriver = driver; // 2?????????????????

    // persister???
    // TODO: MrtPersisterConfig??
    FilePersisterConfig persisterConf = config.getPersisterConfig().getFile();
    String EXPECTED_FOLDER = "results_for_FileParameterTest";
    assertEquals(EXPECTED_FOLDER, persisterConf.getResultDirectory());
    //      assertTrue(new File(EXPECTED_FOLDER).exists()); // ???????.

    String EXPECTED_BASE_URL = "http://localhost:8080/dummyUrl";
    assertEquals(EXPECTED_BASE_URL, driver.getCurrentUrl()); // ?????URL????????

    // ???
    long EXPECTED_WIDTH = 1200l;
    assertEquals(EXPECTED_WIDTH, appConfig.getWindowWidth());
    assertEquals(EXPECTED_WIDTH, driver.executeScript("return window.outerWidth"));

    long EXPECTED_HEIGHT = 980l;
    assertEquals(EXPECTED_HEIGHT, appConfig.getWindowHeight());
    assertEquals(EXPECTED_HEIGHT, driver.executeScript("return window.outerHeight"));
}

From source file:com.jaliansystems.customiSE.example.TestCalc.java

License:Apache License

private String findJavaExe() {
    String exe = "java";
    if (Platform.getCurrent().is(Platform.WINDOWS))
        exe = "java.exe";
    File binDir = new File(System.getProperty("java.home"), "bin");
    if (binDir.isDirectory()) {
        File exeFile = new File(binDir, exe);
        if (exeFile.exists())
            try {
                return exeFile.getCanonicalPath();
            } catch (IOException e) {
            }// ww  w  .ja v a  2 s  . co m
    }
    return null;
}

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

License:Apache License

private void setUpNPMScript() {
    if (npmScript != null) {
        return;//from  ww w. j a  v a  2  s  .  c  o  m
    }

    if (!Platform.getCurrent().is(Platform.WINDOWS)) {
        npmScript = Scripts.GET_PATH_TO_DEFAULT_NODE_UNIX.getScriptFile();
    }
}

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

License:Apache License

private File findNodeInCurrentFileSystem() {
    setUpNPMScript();/*from w w  w  . j  a  v a  2 s. c o  m*/

    String instancePath;
    CommandLine commandLine;
    try {
        if (Platform.getCurrent().is(Platform.WINDOWS)) {
            commandLine = new CommandLine(CMD_EXE, "/C", "npm root -g");
        } else {
            commandLine = new CommandLine(BASH, "-l", npmScript.getAbsolutePath());
        }
        commandLine.execute();
    } catch (Throwable e) {
        throw new RuntimeException(e);
    }

    instancePath = (commandLine.getStdOut()).trim();
    try {
        File defaultAppiumNode;
        if (StringUtils.isBlank(instancePath)
                || !(defaultAppiumNode = new File(instancePath + File.separator + APPIUM_FOLDER)).exists()) {
            String errorOutput = commandLine.getStdOut();
            throw new InvalidServerInstanceException(ERROR_NODE_NOT_FOUND, new IOException(errorOutput));
        }
        //appium?v1.5
        File result;
        if ((result = new File(defaultAppiumNode, APPIUM_NODE_MASK)).exists()) {
            return result;
        }

        throw new InvalidServerInstanceException(ERROR_NODE_NOT_FOUND, new IOException(
                "?" + APPIUM_NODE_MASK + "," + defaultAppiumNode + ""));
    } finally {
        commandLine.destroy();
    }
}

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

License:Apache License

@Override
protected File findDefaultExecutable() {

    String nodeJSExec = System.getProperty(NODE_PATH);
    if (StringUtils.isBlank(nodeJSExec)) {
        nodeJSExec = System.getenv(NODE_PATH);
    }/* w  ww.j  a  va2 s  .  c  om*/
    if (!StringUtils.isBlank(nodeJSExec)) {
        File result = new File(nodeJSExec);
        if (result.exists()) {
            return result;
        }
    }

    CommandLine commandLine;
    setUpGetNodeJSExecutableScript();
    try {
        if (Platform.getCurrent().is(Platform.WINDOWS)) {
            commandLine = new CommandLine(NODE + ".exe", getNodeJSExecutable.getAbsolutePath());
        } else {
            commandLine = new CommandLine(NODE, getNodeJSExecutable.getAbsolutePath());
        }
        commandLine.execute();
    } catch (Throwable t) {
        throw new InvalidNodeJSInstance("Node.js!", t);
    }

    String filePath = (commandLine.getStdOut()).trim();

    try {
        if (StringUtils.isBlank(filePath) || !new File(filePath).exists()) {
            String errorOutput = commandLine.getStdOut();
            String errorMessage = "Can't get a path to the default Node.js instance";
            throw new InvalidNodeJSInstance(errorMessage, new IOException(errorOutput));
        }
        return new File(filePath);
    } finally {
        commandLine.destroy();
    }
}

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 .ja  v a 2s .  c  o  m
    return parseCapabilitiesIfUNIX();
}

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

License:Apache License

private static List<String> buildMobilePaths() {
    ImmutableList.Builder<String> paths = ImmutableList.builder();

    if (platform.is(Platform.WINDOWS)) {
        paths.addAll(WindowsUtils.getPathsInProgramFiles("Opera Mobile Emulator\\OperaMobileEmu.exe"));
        return paths.build();
    }//from  ww w  . j  ava 2  s . co m

    String path = "";
    switch (platform) {
    case LINUX:
    case UNIX:
        path = "/usr/bin";
        break;

    case MAC:
        path = "/Applications/Opera Mobile Emulator.app/Contents/Resources/Opera Mobile.app/Contents/MacOS";
        break;
    }

    for (String binary : buildMobileBinaries()) {
        paths.add(path + binary);
    }

    return paths.build();
}

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 {//  ww  w.j  a v a 2s  . c o  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  w  w w  . j a  va2s.com
    // 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();//w  w w . j  av a  2s  .  co m

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