Search in sources :

Example 11 with ProcessInfo

use of com.seleniumtests.util.osutility.ProcessInfo in project seleniumRobot by bhecquet.

the class LocalAppiumLauncher method startAppiumWithWait.

/**
 * Start appium and wait for availability
 * To work around windows launching, which spawns a new cmd (we cannot stop the underlying node process),
 * get the node process PID associated to the newly created appium
 */
public void startAppiumWithWait() {
    synchronized (appiumLauncherLock) {
        List<ProcessInfo> nodeProcessesInitial = OSUtilityFactory.getInstance().getRunningProcesses("node");
        startAppiumWithoutWait();
        // wait for startup
        waitAppiumAlive();
        for (ProcessInfo nodeProcess : OSUtilityFactory.getInstance().getRunningProcesses("node")) {
            if (!nodeProcessesInitial.contains(nodeProcess)) {
                appiumNodeProcess = nodeProcess;
                break;
            }
        }
    }
}
Also used : ProcessInfo(com.seleniumtests.util.osutility.ProcessInfo)

Example 12 with ProcessInfo

use of com.seleniumtests.util.osutility.ProcessInfo in project seleniumRobot by bhecquet.

the class TestOsUtility method testWhichInternetExplorerWebBrowserRunning.

@Test(groups = { "it" })
public void testWhichInternetExplorerWebBrowserRunning() {
    if (OSUtility.isWindows()) {
        osUtil.killAllWebBrowserProcess(true);
        SeleniumTestsContextManager.getThreadContext().setBrowser("iexplore");
        WebUIDriver.getWebDriver(true);
        List<ProcessInfo> pis = osUtil.whichWebBrowserRunning();
        for (ProcessInfo pi : pis) {
            if (pi.getName().contains("iexplore")) {
                return;
            }
        }
        Assert.fail("Internet Explorer has not been found");
    }
}
Also used : ProcessInfo(com.seleniumtests.util.osutility.ProcessInfo) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 13 with ProcessInfo

use of com.seleniumtests.util.osutility.ProcessInfo in project seleniumRobot by bhecquet.

the class TestOsUtility method testWhichSafariWebBrowserRunning.

@Test(groups = { "it" })
public void testWhichSafariWebBrowserRunning() {
    if (OSUtility.isMac()) {
        osUtil.killAllWebBrowserProcess(true);
        SeleniumTestsContextManager.getThreadContext().setBrowser("safari");
        WebUIDriver.getWebDriver(true);
        List<ProcessInfo> pis = osUtil.whichWebBrowserRunning();
        for (ProcessInfo pi : pis) {
            if (pi.getName().contains("safari")) {
                return;
            }
        }
        Assert.fail("Safari has not been found");
    }
}
Also used : ProcessInfo(com.seleniumtests.util.osutility.ProcessInfo) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 14 with ProcessInfo

use of com.seleniumtests.util.osutility.ProcessInfo in project seleniumRobot by bhecquet.

the class TestOsUtility method testWhichEdgeWebBrowserRunning.

@Test(groups = { "it" })
public void testWhichEdgeWebBrowserRunning() {
    if (OSUtility.isWindows10()) {
        osUtil.killAllWebBrowserProcess(true);
        SeleniumTestsContextManager.getThreadContext().setBrowser("edge");
        WebUIDriver.getWebDriver(true);
        List<ProcessInfo> pis = osUtil.whichWebBrowserRunning();
        for (ProcessInfo pi : pis) {
            if (pi.getName().contains("edge")) {
                return;
            }
        }
        Assert.fail("Edge has not been found");
    }
}
Also used : ProcessInfo(com.seleniumtests.util.osutility.ProcessInfo) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 15 with ProcessInfo

use of com.seleniumtests.util.osutility.ProcessInfo in project seleniumRobot by bhecquet.

the class TestOsUtility method testKillProcess.

@Test(groups = { "it" })
public void testKillProcess() {
    if (OSUtility.isWindows()) {
        OSCommand.executeCommand("calc");
        WaitHelper.waitForSeconds(2);
        ProcessInfo pi = osUtil.getRunningProcess("calc");
        if (pi == null) {
            // Windows 10
            pi = osUtil.getRunningProcess("calculator");
        }
        if (pi == null) {
            // Windows 10
            pi = osUtil.getRunningProcess("Calculator");
        }
        if (pi == null) {
            // Windows 2016
            pi = osUtil.getRunningProcess("win32calc");
        }
        if (pi == null) {
            throw new ConfigurationException("Cannot find process 'calc', 'win32calc' or 'calculator'");
        }
        osUtil.killProcess(pi.getPid(), true);
        Assert.assertNull(osUtil.getRunningProcess("calc"));
        Assert.assertNull(osUtil.getRunningProcess("calculator"));
        Assert.assertNull(osUtil.getRunningProcess("Calculator"));
        Assert.assertNull(osUtil.getRunningProcess("win32calc"));
    }
}
Also used : ConfigurationException(com.seleniumtests.customexception.ConfigurationException) ProcessInfo(com.seleniumtests.util.osutility.ProcessInfo) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

ProcessInfo (com.seleniumtests.util.osutility.ProcessInfo)16 GenericTest (com.seleniumtests.GenericTest)15 Test (org.testng.annotations.Test)15 MockitoTest (com.seleniumtests.MockitoTest)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)1