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;
}
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;
}
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");
}
}
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);
}
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);
}
Aggregations