use of com.seleniumtests.driver.BrowserType 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.driver.BrowserType 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.driver.BrowserType in project seleniumRobot by bhecquet.
the class TestWebUiDriver method testAttachExternalChromeBrowserStartingLate.
/**
* Be sure that we can still attach driver even if it takes a long time to start
* For chrome, max wait time is 1 minute
*/
@Test(groups = { "it" })
public void testAttachExternalChromeBrowserStartingLate() {
SeleniumTestsContextManager.getThreadContext().setTestType(TestType.WEB);
Map<BrowserType, List<BrowserInfo>> browsers = OSUtility.getInstalledBrowsersWithVersion();
String path = browsers.get(BrowserType.CHROME).get(0).getPath();
int port = GenericDriverTest.findFreePort();
logger.info("will start browser in 15 secs");
new BrowserLauncher(BrowserType.CHROME, port, path, 30, null).run();
logger.info("Waiting for driver");
// creates the driver
WebDriver driver1 = WebUIDriver.getWebDriver(true, BrowserType.CHROME, "main", port);
driver1.get("chrome://settings/");
Assert.assertTrue(new TextFieldElement("search", By.id("search")).isElementPresent(3));
}
use of com.seleniumtests.driver.BrowserType in project seleniumRobot by bhecquet.
the class TestWebUiDriver method testAttachExternalEdgeBrowser.
@Test(groups = { "it" })
public void testAttachExternalEdgeBrowser() {
if (!SystemUtils.IS_OS_WINDOWS) {
throw new SkipException("This test can only be done on Windows");
}
SeleniumTestsContextManager.getThreadContext().setTestType(TestType.WEB);
Map<BrowserType, List<BrowserInfo>> browsers = OSUtility.getInstalledBrowsersWithVersion();
String path = browsers.get(BrowserType.EDGE).get(0).getPath();
int port = GenericDriverTest.findFreePort();
// create chrome browser with the right option
new BrowserLauncher(BrowserType.EDGE, port, path, 0, null).run();
// creates the driver
WebDriver driver1 = WebUIDriver.getWebDriver(true, BrowserType.EDGE, "main", port);
driver1.get("edge://settings/");
Assert.assertTrue(new TextFieldElement("search", By.id("search_input")).isElementPresent(3));
}
use of com.seleniumtests.driver.BrowserType in project seleniumRobot by bhecquet.
the class TestChromeCapabilityFactory method testNonBetaVersionBrowserAbsent.
/**
* If beta is not requested, and non beta browser not installed, return null
*/
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class, expectedExceptionsMessageRegExp = "Browser CHROME is not available")
public void testNonBetaVersionBrowserAbsent() {
when(config.getMode()).thenReturn(DriverMode.LOCAL);
Map<BrowserType, List<BrowserInfo>> browserInfos = new HashMap<>();
browserInfos.put(BrowserType.CHROME, Arrays.asList(new BrowserInfo(BrowserType.CHROME, "97.0", "", false, true)));
PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(false)).thenReturn(browserInfos);
ChromeCapabilitiesFactory capaFactory = new ChromeCapabilitiesFactory(config);
capaFactory.createCapabilities();
}
Aggregations