Search in sources :

Example 36 with BrowserInfo

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

the class OSUtilityMac method discoverInstalledBrowsersWithVersion.

@Override
public Map<BrowserType, List<BrowserInfo>> discoverInstalledBrowsersWithVersion(boolean discoverBetaBrowsers) {
    Map<BrowserType, List<BrowserInfo>> browserList = new EnumMap<>(BrowserType.class);
    browserList.put(BrowserType.HTMLUNIT, Arrays.asList(new BrowserInfo(BrowserType.HTMLUNIT, BrowserInfo.LATEST_VERSION, null)));
    browserList.put(BrowserType.PHANTOMJS, Arrays.asList(new BrowserInfo(BrowserType.PHANTOMJS, BrowserInfo.LATEST_VERSION, null)));
    // safari is always installed on mac os
    browserList.put(BrowserType.SAFARI, Arrays.asList(new BrowserInfo(BrowserType.SAFARI, BrowserInfo.LATEST_VERSION, null)));
    // TODO: handle multiple installation of Chrome and Firefox. But how to do that without specifying the location
    if (new File("/Applications/Google Chrome.app").isDirectory()) {
        String version = getChromeVersion("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
        browserList.put(BrowserType.CHROME, Arrays.asList(new BrowserInfo(BrowserType.CHROME, extractChromeVersion(version), "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome")));
    }
    if (new File("/Applications/Firefox.app").isDirectory()) {
        String version = getFirefoxVersion("/Applications/Firefox.app/Contents/MacOS/firefox");
        browserList.put(BrowserType.FIREFOX, Arrays.asList(new BrowserInfo(BrowserType.FIREFOX, extractFirefoxVersion(version), "/Applications/Firefox.app/Contents/MacOS/firefox")));
    }
    return browserList;
}
Also used : BrowserType(com.seleniumtests.driver.BrowserType) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) List(java.util.List) EnumMap(java.util.EnumMap) File(java.io.File)

Example 37 with BrowserInfo

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

the class OSUtilityUnix method discoverInstalledBrowsersWithVersion.

@Override
public Map<BrowserType, List<BrowserInfo>> discoverInstalledBrowsersWithVersion(boolean discoverBetaBrowsers) {
    Map<BrowserType, List<BrowserInfo>> browserList = new EnumMap<>(BrowserType.class);
    browserList.put(BrowserType.HTMLUNIT, Arrays.asList(new BrowserInfo(BrowserType.HTMLUNIT, BrowserInfo.LATEST_VERSION, null)));
    browserList.put(BrowserType.PHANTOMJS, Arrays.asList(new BrowserInfo(BrowserType.PHANTOMJS, BrowserInfo.LATEST_VERSION, null)));
    // TODO: handle multiple installation of firefox and Chrome
    String firefoxLocation = OSCommand.executeCommandAndWait("which firefox").trim();
    String iceweaselLocation = OSCommand.executeCommandAndWait("which iceweasel").trim();
    String chromeLocation = OSCommand.executeCommandAndWait("which google-chrome").trim();
    String chromiumLocation = OSCommand.executeCommandAndWait("which chromium-browser").trim();
    if (!firefoxLocation.isEmpty() && !firefoxLocation.contains(WHICH_ERROR)) {
        String version = getFirefoxVersion("firefox");
        List<BrowserInfo> arrayFirefox = new ArrayList<>();
        arrayFirefox.add(new BrowserInfo(BrowserType.FIREFOX, extractFirefoxVersion(version), firefoxLocation));
        browserList.put(BrowserType.FIREFOX, arrayFirefox);
    } else if (!iceweaselLocation.isEmpty() && !iceweaselLocation.contains(WHICH_ERROR)) {
        String version = getFirefoxVersion("iceweasel");
        List<BrowserInfo> arrayIceWeasel = new ArrayList<>();
        arrayIceWeasel.add(new BrowserInfo(BrowserType.FIREFOX, extractFirefoxVersion(version), iceweaselLocation));
        browserList.put(BrowserType.FIREFOX, arrayIceWeasel);
    }
    if (!chromiumLocation.isEmpty() && !chromiumLocation.contains(WHICH_ERROR)) {
        String version = getChromeVersion("chromium-browser");
        List<BrowserInfo> arrayChromium = new ArrayList<>();
        arrayChromium.add(new BrowserInfo(BrowserType.CHROME, extractChromiumVersion(version), chromiumLocation));
        browserList.put(BrowserType.CHROME, arrayChromium);
    } else if (!chromeLocation.isEmpty() && !chromeLocation.contains(WHICH_ERROR)) {
        String version = getChromeVersion("google-chrome");
        List<BrowserInfo> arrayChrome = new ArrayList<>();
        arrayChrome.add(new BrowserInfo(BrowserType.CHROME, extractChromeVersion(version), chromeLocation));
        browserList.put(BrowserType.CHROME, arrayChrome);
    }
    return browserList;
}
Also used : BrowserType(com.seleniumtests.driver.BrowserType) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) EnumMap(java.util.EnumMap)

Example 38 with BrowserInfo

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

the class TestBrowserInfo method testIE9Version.

@Test(groups = { "ut" })
public void testIE9Version() {
    if (SystemUtils.IS_OS_WINDOWS) {
        BrowserInfo bInfo = new BrowserInfo(BrowserType.INTERNET_EXPLORER, "9", null);
        Assert.assertEquals(bInfo.getDriverFileName(), "IEDriverServer_x64");
    }
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 39 with BrowserInfo

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

the class TestBrowserInfo method testGetDriverFilesWithNotInstalledArtifact.

/**
 * If artifact is not installed, getDriverListFromJarResources raises NullPointerException
 * @throws Exception
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testGetDriverFilesWithNotInstalledArtifact() throws Exception {
    PowerMockito.mockStatic(OSUtility.class);
    when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.WINDOWS);
    BrowserInfo bInfo = PowerMockito.spy(new BrowserInfo(BrowserType.CHROME, "55.0", null));
    PowerMockito.when(bInfo, "getDriverListFromJarResources", "driver-list-windows.txt").thenThrow(NullPointerException.class);
    Assert.assertEquals(bInfo.getDriverFiles().size(), 3);
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 40 with BrowserInfo

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

the class TestBrowserInfo method testHighestDriverVersionNullBrowserInfo.

@Test(groups = { "ut" })
public void testHighestDriverVersionNullBrowserInfo() {
    BrowserInfo bi1 = new BrowserInfo(BrowserType.CHROME, "48.0", null);
    BrowserInfo bi2 = new BrowserInfo(BrowserType.CHROME, "58.0", null);
    BrowserInfo highestBi = BrowserInfo.getHighestDriverVersion(Arrays.asList(bi1, null, bi2));
    Assert.assertEquals(highestBi, bi2);
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

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