Search in sources :

Example 26 with BrowserInfo

use of com.seleniumtests.browserfactory.BrowserInfo in project seleniumRobot by bhecquet.

the class TestBrowserInfo method testBrowserInfoInternetExplorer.

@Test(groups = { "it" })
public void testBrowserInfoInternetExplorer() {
    if (!SystemUtils.IS_OS_WINDOWS) {
        throw new SkipException("This test can only be done on Windows");
    }
    BrowserInfo browserInfo = new BrowserInfo(BrowserType.INTERNET_EXPLORER, "11", "/some/path", false);
    browserInfo.getDriverFileName();
    Assert.assertTrue(browserInfo.isDriverFileSearched());
    Assert.assertEquals(browserInfo.getDriverFileName(), "IEDriverServer_Win32");
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) SkipException(org.testng.SkipException) GenericDriverTest(com.seleniumtests.GenericDriverTest) Test(org.testng.annotations.Test)

Example 27 with BrowserInfo

use of com.seleniumtests.browserfactory.BrowserInfo in project seleniumRobot by bhecquet.

the class TestBrowserInfo method testBrowserInfoLegacyFirefox.

@Test(groups = { "it" })
public void testBrowserInfoLegacyFirefox() {
    BrowserInfo browserInfo = new BrowserInfo(BrowserType.FIREFOX, "47.0", "/some/path", false);
    browserInfo.getDriverFileName();
    Assert.assertTrue(browserInfo.isDriverFileSearched());
    // for legacy version, no driver file name should be found
    Assert.assertNull(browserInfo.getDriverFileName());
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) GenericDriverTest(com.seleniumtests.GenericDriverTest) Test(org.testng.annotations.Test)

Example 28 with BrowserInfo

use of com.seleniumtests.browserfactory.BrowserInfo in project seleniumRobot by bhecquet.

the class AdbWrapper method getInstalledBrowsers.

private List<BrowserInfo> getInstalledBrowsers(String deviceId) {
    List<BrowserInfo> browsers = new ArrayList<>();
    String reply = OSCommand.executeCommandAndWait(String.format("%s -s %s shell \"pm list packages\"", adbCommand, deviceId));
    for (String line : reply.split("\n")) {
        if (line.contains("package:com.android.chrome")) {
            String chromeVersion = OSCommand.executeCommandAndWait(String.format("%s -s %s shell \"dumpsys package com.android.chrome | grep versionName\"", adbCommand, deviceId));
            Matcher versionMatcher = REG_CHROME_VERSION_NAME.matcher(chromeVersion.trim());
            if (versionMatcher.matches()) {
                browsers.add(new BrowserInfo(BrowserType.CHROME, versionMatcher.group(1), null));
            } else {
                logger.error(String.format("Cannot parse chrome version %s", chromeVersion));
                browsers.add(new BrowserInfo(BrowserType.CHROME, chromeVersion, null));
            }
        }
        if (line.contains("package:com.android.browser")) {
            String androidVersion = OSCommand.executeCommandAndWait(String.format("%s -s %s shell \"dumpsys package com.android.browser | grep versionName\"", adbCommand, deviceId));
            Matcher versionMatcher = REG_BROWSER_VERSION_NAME.matcher(androidVersion.trim());
            if (versionMatcher.matches()) {
                browsers.add(new BrowserInfo(BrowserType.BROWSER, versionMatcher.group(1), null));
            } else {
                logger.error(String.format("Cannot parse android browser version %s", androidVersion));
                browsers.add(new BrowserInfo(BrowserType.BROWSER, androidVersion, null));
            }
        }
    }
    return browsers;
}
Also used : Matcher(java.util.regex.Matcher) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) ArrayList(java.util.ArrayList)

Example 29 with BrowserInfo

use of com.seleniumtests.browserfactory.BrowserInfo in project seleniumRobot by bhecquet.

the class InstrumentsWrapper method parseIosDevices.

/**
 * Use 'instruments -s devices' to know which devices are available for test
 */
public List<MobileDevice> parseIosDevices() {
    String output = OSCommand.executeCommandAndWait("instruments -s devices");
    List<MobileDevice> devList = new ArrayList<>();
    for (String line : output.split("\n")) {
        line = line.trim();
        Matcher matcher = REG_DEVICE.matcher(line);
        if (matcher.matches()) {
            MobileDevice dev = new MobileDevice(matcher.group(1).trim(), matcher.group(3), "iOS", matcher.group(2), Arrays.asList(new BrowserInfo(BrowserType.SAFARI, "latest", null)));
            devList.add(dev);
        }
    }
    return devList;
}
Also used : Matcher(java.util.regex.Matcher) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) ArrayList(java.util.ArrayList)

Example 30 with BrowserInfo

use of com.seleniumtests.browserfactory.BrowserInfo in project seleniumRobot by bhecquet.

the class SeleniumTestsContext method updateInstalledBrowsers.

/**
 * If chrome or firefox binary is redefined in parameter, update list of installed browser so
 * that it matches those really used
 */
private void updateInstalledBrowsers() {
    Map<BrowserType, List<BrowserInfo>> installedBrowsers = OSUtility.getInstalledBrowsersWithVersion(getBetaBrowser());
    if (getFirefoxBinPath() != null) {
        String version = OSUtility.getFirefoxVersion(getFirefoxBinPath());
        installedBrowsers.get(BrowserType.FIREFOX).add(new BrowserInfo(BrowserType.FIREFOX, OSUtility.extractFirefoxVersion(version), getFirefoxBinPath()));
    }
    if (getChromeBinPath() != null) {
        String version = OSUtility.getChromeVersion(getChromeBinPath());
        installedBrowsers.get(BrowserType.CHROME).add(new BrowserInfo(BrowserType.CHROME, OSUtility.extractChromeOrChromiumVersion(version), getChromeBinPath()));
    }
}
Also used : BrowserType(com.seleniumtests.driver.BrowserType) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)71 Test (org.testng.annotations.Test)59 MockitoTest (com.seleniumtests.MockitoTest)53 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)53 ArrayList (java.util.ArrayList)23 List (java.util.List)19 BrowserType (com.seleniumtests.driver.BrowserType)18 HashMap (java.util.HashMap)14 MutableCapabilities (org.openqa.selenium.MutableCapabilities)9 GenericDriverTest (com.seleniumtests.GenericDriverTest)6 ChromeCapabilitiesFactory (com.seleniumtests.browserfactory.ChromeCapabilitiesFactory)5 EdgeCapabilitiesFactory (com.seleniumtests.browserfactory.EdgeCapabilitiesFactory)5 CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 EnumMap (java.util.EnumMap)3 Map (java.util.Map)3 SkipException (org.testng.SkipException)3 FirefoxCapabilitiesFactory (com.seleniumtests.browserfactory.FirefoxCapabilitiesFactory)2 IECapabilitiesFactory (com.seleniumtests.browserfactory.IECapabilitiesFactory)2 MobileDevice (com.seleniumtests.browserfactory.mobile.MobileDevice)2