use of com.seleniumtests.browserfactory.BrowserInfo in project seleniumRobot by bhecquet.
the class WebUIDriver method checkBrowserRunnable.
private void checkBrowserRunnable() {
if (config.getMode() == DriverMode.LOCAL && !config.getTestType().isMobile()) {
Map<BrowserType, List<BrowserInfo>> browsers = OSUtility.getInstalledBrowsersWithVersion(config.getBetaBrowser());
if (!browsers.containsKey(config.getBrowserType()) || browsers.get(config.getBrowserType()).isEmpty()) {
throw new ConfigurationException(String.format("Browser %s is not available. Available browsers are %s", config.getBrowserType(), browsers));
}
boolean browserFound = false;
for (BrowserInfo browserInfo : browsers.get(config.getBrowserType())) {
if (config.getBetaBrowser().equals(browserInfo.getBeta())) {
browserFound = true;
break;
}
}
if (!browserFound) {
throw new ConfigurationException(String.format("Browser %s %s is not available. Available browsers are %s", config.getBrowserType(), config.getBetaBrowser() ? "beta" : "", browsers));
}
}
}
use of com.seleniumtests.browserfactory.BrowserInfo in project seleniumRobot by bhecquet.
the class OSUtilityWindows 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)));
// look for Firefox
try {
browserList.put(BrowserType.FIREFOX, new ArrayList<>());
for (String firefoxPath : searchFirefoxVersions()) {
String version = getFirefoxVersion(firefoxPath);
try {
browserList.get(BrowserType.FIREFOX).add(new BrowserInfo(BrowserType.FIREFOX, extractFirefoxVersion(version), firefoxPath));
} catch (ConfigurationException e) {
// ignore
}
}
} catch (IndexOutOfBoundsException e) {
// ignore
}
// look for chrome
try {
browserList.put(BrowserType.CHROME, new ArrayList<>());
// main chrome version
String chromePath = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, "Software\\Classes\\ChromeHTML\\shell\\open\\command", "");
chromePath = chromePath.split(EXE_EXT_QUOTE)[0].replace("\"", "") + ".exe";
String version = getWindowsChromeVersion(chromePath);
browserList.get(BrowserType.CHROME).add(new BrowserInfo(BrowserType.CHROME, extractChromeVersion("Google Chrome " + version), false, chromePath));
} catch (Win32Exception | ConfigurationException e) {
logger.warn("Error searching chrome installations: " + e.getMessage());
}
try {
// beta chrome version
String chromeBetaPath = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, "Software\\Classes\\ChromeBHTML\\shell\\open\\command", "");
chromeBetaPath = chromeBetaPath.split(EXE_EXT_QUOTE)[0].replace("\"", "") + ".exe";
String versionBeta;
versionBeta = getWindowsBetaChromeVersion(chromeBetaPath);
browserList.get(BrowserType.CHROME).add(new BrowserInfo(BrowserType.CHROME, extractChromeVersion("Google Chrome " + versionBeta), true, chromeBetaPath));
} catch (Win32Exception | ConfigurationException e) {
logger.warn("Error searching Beta chrome installations: " + e.getMessage());
}
// look for ie
try {
Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE", "");
String version = getIeVersionFromRegistry();
browserList.put(BrowserType.INTERNET_EXPLORER, Arrays.asList(new BrowserInfo(BrowserType.INTERNET_EXPLORER, extractIEVersion(version), null)));
} catch (Win32Exception | ConfigurationException e) {
logger.warn("Error searching Internet explorer installations: " + e.getMessage());
}
// look for edge chromium
try {
browserList.put(BrowserType.EDGE, new ArrayList<>());
String edgePath = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, "Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Microsoft Edge", "InstallLocation");
String version = getWindowsEdgeVersion(edgePath);
if (version != null && !version.isEmpty()) {
browserList.get(BrowserType.EDGE).add(new BrowserInfo(BrowserType.EDGE, extractEdgeVersion(version), false, Paths.get(edgePath, MSEDGE_EXE).toString()));
}
} catch (Win32Exception | ConfigurationException e) {
logger.warn("Error searching Edge chromium installations: " + e.getMessage());
}
try {
// beta edge version
String edgePathBeta = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, "Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Microsoft Edge Beta", "InstallLocation");
String versionBeta = getWindowsBetaEdgeVersion(edgePathBeta);
if (versionBeta != null && !versionBeta.isEmpty()) {
browserList.get(BrowserType.EDGE).add(new BrowserInfo(BrowserType.EDGE, extractEdgeVersion(versionBeta), true, Paths.get(edgePathBeta, MSEDGE_EXE).toString()));
}
} catch (Win32Exception | ConfigurationException e) {
logger.warn("Error searching Beta Edge chromium installations: " + e.getMessage());
}
return browserList;
}
use of com.seleniumtests.browserfactory.BrowserInfo in project seleniumRobot by bhecquet.
the class TestBrowserInfo method testBrowserInfoEdge.
@Test(groups = { "it" })
public void testBrowserInfoEdge() {
if (!SystemUtils.IS_OS_WINDOWS_10) {
throw new SkipException("This test can only be done on Windows 10");
}
BrowserInfo browserInfo = new BrowserInfo(BrowserType.EDGE, "98.0", "/some/path", false);
browserInfo.getDriverFileName();
Assert.assertTrue(browserInfo.isDriverFileSearched());
Assert.assertEquals(browserInfo.getDriverFileName(), "edgedriver_98.0_edge-98-99");
}
use of com.seleniumtests.browserfactory.BrowserInfo in project seleniumRobot by bhecquet.
the class TestBrowserInfo method testBrowserInfoChrome.
@Test(groups = { "it" })
public void testBrowserInfoChrome() {
BrowserInfo browserInfo = new BrowserInfo(BrowserType.CHROME, "99.0", "/some/path", false);
browserInfo.getDriverFileName();
Assert.assertTrue(browserInfo.isDriverFileSearched());
Assert.assertEquals(browserInfo.getDriverFileName(), "chromedriver_99.0_chrome-99-100");
}
use of com.seleniumtests.browserfactory.BrowserInfo in project seleniumRobot by bhecquet.
the class TestBrowserInfo method testBrowserInfoSafari.
@Test(groups = { "it" })
public void testBrowserInfoSafari() {
if (!SystemUtils.IS_OS_MAC_OSX) {
throw new SkipException("This test can only be done on Mac OS X");
}
BrowserInfo browserInfo = new BrowserInfo(BrowserType.SAFARI, "7.0", "/some/path", false);
browserInfo.getDriverFileName();
Assert.assertTrue(browserInfo.isDriverFileSearched());
Assert.assertNull(browserInfo.getDriverFileName());
}
Aggregations