Java Code Examples for org.openqa.selenium.remote.BrowserType#CHROME
The following examples show how to use
org.openqa.selenium.remote.BrowserType#CHROME .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestingBotPaasHandler.java From KITE with Apache License 2.0 | 6 votes |
@Override public void fetchConfig() throws IOException { List<JsonObject> availableConfigList = this.getAvailableConfigList(null, null); /* might be not necessary, depending on data format it DB */ for (JsonObject jsonObject : availableConfigList) { Client client = new Client(); client.getBrowserSpecs().setVersion(jsonObject.getString("version", "")); String browserName = jsonObject.getString("name", ""); if (browserName.endsWith("edge")) browserName = BrowserType.EDGE; else if (browserName.equalsIgnoreCase(BrowserType.GOOGLECHROME)) browserName = BrowserType.CHROME; client.getBrowserSpecs().setBrowserName(browserName); String platform = jsonObject.getString("platform", ""); client.getBrowserSpecs().setPlatform( platform.equalsIgnoreCase("CAPITAN") ? Platform.EL_CAPITAN : Platform.fromString(platform)); this.clientList.add(client); } }
Example 2
Source File: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 6 votes |
@Test public void ignoresVersionStringIfEmpty() { Capabilities anyChrome = new DesiredCapabilities(BrowserType.CHROME, "10", Platform.ANY); Capabilities chromeNoVersion = new DesiredCapabilities() {{ setBrowserName(BrowserType.CHROME); setPlatform(Platform.UNIX); }}; Capabilities chromeEmptyVersion = new DesiredCapabilities(chromeNoVersion) {{ setVersion(""); }}; List<Capabilities> allCaps = asList(anyChrome, chromeNoVersion); assertThat(getBestMatch(chromeEmptyVersion, allCaps, Platform.UNIX)).isEqualTo(chromeNoVersion); assertThat(getBestMatch(chromeNoVersion, allCaps, Platform.UNIX)).isEqualTo(chromeNoVersion); // Unix does not match windows. assertThat(getBestMatch(anyChrome, allCaps, Platform.WINDOWS)).isEqualTo(anyChrome); }
Example 3
Source File: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 6 votes |
@Test public void currentPlatformCheckDoesNotTrumpExactPlatformMatch() { Capabilities chromeUnix = capabilities(BrowserType.CHROME, "", Platform.UNIX, true); Capabilities chromeVista = capabilities(BrowserType.CHROME, "", Platform.VISTA, true); Capabilities anyChrome = new DesiredCapabilities(BrowserType.CHROME, "10", Platform.ANY); List<Capabilities> allCaps = asList(anyChrome, chromeVista, chromeUnix); assertThat(getBestMatch(chromeVista, allCaps, Platform.UNIX)).isEqualTo(chromeVista); assertThat(getBestMatch(chromeVista, allCaps, Platform.LINUX)).isEqualTo(chromeVista); assertThat(getBestMatch(chromeVista, allCaps, Platform.MAC)).isEqualTo(chromeVista); assertThat(getBestMatch(chromeUnix, allCaps, Platform.MAC)).isEqualTo(chromeUnix); assertThat(getBestMatch(chromeUnix, allCaps, Platform.VISTA)).isEqualTo(chromeUnix); assertThat(getBestMatch(chromeUnix, allCaps, Platform.WINDOWS)).isEqualTo(chromeUnix); }
Example 4
Source File: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 6 votes |
@Test public void shouldPickCorrectBrowser() { Capabilities chrome = new DesiredCapabilities(BrowserType.CHROME, "10", Platform.ANY); Capabilities firefox = new DesiredCapabilities(BrowserType.FIREFOX, "10", Platform.ANY); Capabilities opera = new DesiredCapabilities(BrowserType.OPERA_BLINK, "10", Platform.ANY); List<Capabilities> list = asList(chrome, firefox, opera); DesiredCapabilities desired = new DesiredCapabilities(); desired.setBrowserName(BrowserType.CHROME); assertThat(getBestMatch(desired, list)).isEqualTo(chrome); desired.setBrowserName(BrowserType.FIREFOX); assertThat(getBestMatch(desired, list)).isEqualTo(firefox); desired.setBrowserName(BrowserType.OPERA_BLINK); assertThat(getBestMatch(desired, list)).isEqualTo(opera); }
Example 5
Source File: BrowserSpecs.java From KITE with Apache License 2.0 | 6 votes |
/** * Gets the driver string. * * @return the driver string */ @Transient public String getDriverString() { String driverString = ""; switch (this.getBrowserName()) { // Selenium case BrowserType.CHROME: if (this.getPathToDriver() != null && this.getPathToDriver() != "") { driverString = "-Dwebdriver.chrome.driver=" + this.getPathToDriver(); } else { driverString = "-Dwebdriver.chrome.driver=./chromedriver"; } break; case BrowserType.FIREFOX: if (this.getPathToDriver() != null && this.getPathToDriver() != "") { driverString = "-Dwebdriver.gecko.driver=" + this.getPathToDriver(); } else { driverString = "-Dwebdriver.gecko.driver=./geckodriver"; } break; } return driverString; }
Example 6
Source File: BrowserWebDriverContainer.java From testcontainers-java with MIT License | 5 votes |
public static String getImageForCapabilities(Capabilities capabilities, String seleniumVersion) { String browserName = capabilities.getBrowserName(); switch (browserName) { case BrowserType.CHROME: return String.format(CHROME_IMAGE, seleniumVersion); case BrowserType.FIREFOX: return String.format(FIREFOX_IMAGE, seleniumVersion); default: throw new UnsupportedOperationException("Browser name must be 'chrome' or 'firefox'; provided '" + browserName + "' is not supported"); } }
Example 7
Source File: AssumeCapabilityTest.java From hifive-pitalium with Apache License 2.0 | 5 votes |
@CapabilityFilters({ @CapabilityFilter(filterGroup = "pc", browserName = BrowserType.IE), @CapabilityFilter(platform = Platform.WINDOWS, browserName = { BrowserType.FIREFOX, BrowserType.CHROME }) }) @Test public void multipleFilters() throws Exception { assertAssumed(2, 5, 6, 7, 8); }
Example 8
Source File: WebProxyJsonRenderer.java From selenium-api with MIT License | 5 votes |
private String consoleIconName(DesiredCapabilities cap) { String browserString = cap.getBrowserName(); if (browserString == null || "".equals(browserString)) { return "missingBrowserName"; } String ret = browserString; // Map browser environments to icon names. if (browserString.contains("iexplore") || browserString.startsWith("*iehta")) { ret = BrowserType.IE; } else if (browserString.contains("firefox") || browserString.startsWith("*chrome")) { if (cap.getVersion() != null && cap.getVersion().toLowerCase().equals("beta") || cap.getBrowserName().toLowerCase().contains("beta")) { ret = "firefoxbeta"; } else if (cap.getVersion() != null && cap.getVersion().toLowerCase().equals("aurora") || cap.getBrowserName().toLowerCase().contains("aurora")) { ret = "aurora"; } else if (cap.getVersion() != null && cap.getVersion().toLowerCase().equals("nightly") || cap.getBrowserName().toLowerCase().contains("nightly")) { ret = "nightly"; } else { ret = BrowserType.FIREFOX; } } else if (browserString.startsWith("*safari")) { ret = BrowserType.SAFARI; } else if (browserString.startsWith("*googlechrome")) { ret = BrowserType.CHROME; } else if (browserString.startsWith("opera")) { ret = BrowserType.OPERA; } else if (browserString.toLowerCase().contains("edge")) { ret = BrowserType.EDGE; } return ret.replace(" ", "_"); }
Example 9
Source File: SeleniumEphemeral.java From ephemerals with MIT License | 5 votes |
@Override protected DeploymentUnit createDeploymentUnit() { String browserName = desiredCapabilities.getBrowserName(); logger.info("Selenium browser: {}", browserName); String image; switch (browserName) { case BrowserType.CHROME: image = CHROME_IMAGE; break; case BrowserType.FIREFOX: image = FIREFOX_IMAGE; break; case BrowserType.PHANTOMJS: image = PHANTOMJS_IMAGE; break; default: throw new UnsupportedOperationException("Provided browser type '" + browserName + "' is not supported"); } DeploymentUnit.Builder builder = new DockerDeploymentUnit.Builder("selenium", image) .withCpu(1) .withMem(1024) .withHealthProbe(new HttpProbe.Builder() .withPath(SERVER_PATH) .withPort(SELENIUM_PORT) .build()) .withPort(new DeploymentPort.Builder("selenium-server", SELENIUM_PORT) .build()) .withPort(new DeploymentPort.Builder("vnc-server", VNC_PORT) .build()); if (dimension != null) { builder.withEnvVar("SCREEN_WIDTH", String.valueOf(dimension.getWidth())) .withEnvVar("SCREEN_HEIGHT", String.valueOf(dimension.getHeight())); } return builder.build(); }
Example 10
Source File: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 5 votes |
@Test public void matchesWithPreferenceToCurrentPlatform() { Capabilities chromeUnix = capabilities(BrowserType.CHROME, "", Platform.UNIX, true); Capabilities chromeVista = capabilities(BrowserType.CHROME, "", Platform.VISTA, true); Capabilities anyChrome = new DesiredCapabilities(BrowserType.CHROME, "", Platform.ANY); List<Capabilities> allCaps = asList(anyChrome, chromeVista, chromeUnix, // This last option should never match. new DesiredCapabilities(BrowserType.FIREFOX, "10", Platform.ANY)); // Should match to corresponding platform. assertThat(getBestMatch(anyChrome, allCaps, Platform.UNIX)).isEqualTo(chromeUnix); assertThat(getBestMatch(chromeUnix, allCaps, Platform.UNIX)).isEqualTo(chromeUnix); assertThat(getBestMatch(anyChrome, allCaps, Platform.LINUX)).isEqualTo(chromeUnix); assertThat(getBestMatch(chromeUnix, allCaps, Platform.LINUX)).isEqualTo(chromeUnix); assertThat(getBestMatch(anyChrome, allCaps, Platform.VISTA)).isEqualTo(chromeVista); assertThat(getBestMatch(chromeVista, allCaps, Platform.VISTA)).isEqualTo(chromeVista); assertThat(getBestMatch(anyChrome, allCaps, Platform.WINDOWS)).isEqualTo(chromeVista); assertThat(getBestMatch(chromeVista, allCaps, Platform.WINDOWS)).isEqualTo(chromeVista); // No configs registered to current platform, should fallback to normal matching rules. assertThat(getBestMatch(anyChrome, allCaps, Platform.MAC)).isEqualTo(anyChrome); assertThat(getBestMatch(anyChrome, allCaps, Platform.XP)).isEqualTo(anyChrome); }
Example 11
Source File: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 5 votes |
@Test public void currentPlatformCheckDoesNotTrumpExactVersionMatch() { Capabilities chromeUnix = capabilities(BrowserType.CHROME, "", Platform.UNIX, true); Capabilities chromeBetaUnix = capabilities(BrowserType.CHROME, "beta", Platform.UNIX, true); Capabilities chromeVista = capabilities(BrowserType.CHROME, "", Platform.VISTA, true); Capabilities anyChrome = new DesiredCapabilities(BrowserType.CHROME, "10", Platform.ANY); List<Capabilities> allCaps = asList(anyChrome, chromeVista, chromeUnix, chromeBetaUnix); assertThat(getBestMatch(chromeUnix, allCaps, Platform.UNIX)).isEqualTo(chromeUnix); assertThat(getBestMatch(chromeBetaUnix, allCaps, Platform.UNIX)).isEqualTo(chromeBetaUnix); }
Example 12
Source File: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 5 votes |
@Test public void absentExactMatchPrefersItemsInInputOrder() { Capabilities chromeWindows = capabilities(BrowserType.CHROME, "", Platform.WINDOWS, true); Capabilities chromeVista = capabilities(BrowserType.CHROME, "", Platform.VISTA, true); Capabilities anyChrome = new DesiredCapabilities(BrowserType.CHROME, "10", Platform.ANY); List<Capabilities> allCaps = asList(chromeWindows, chromeVista); List<Capabilities> reversedCaps = Lists.reverse(allCaps); assertThat(getBestMatch(anyChrome, allCaps, Platform.UNIX)).isEqualTo(chromeWindows); assertThat(getBestMatch(anyChrome, reversedCaps, Platform.UNIX)).isEqualTo(chromeVista); }
Example 13
Source File: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 5 votes |
@Test public void filtersByVersionStringIfNonEmpty() { Capabilities anyChrome = new DesiredCapabilities(BrowserType.CHROME, "10", Platform.ANY); Capabilities chromeBeta = new DesiredCapabilities(anyChrome) {{ setVersion("beta"); }}; Capabilities chromeDev = new DesiredCapabilities(anyChrome) {{ setVersion("dev"); }}; List<Capabilities> allCaps = asList(anyChrome, chromeBeta, chromeDev); assertThat(getBestMatch(anyChrome, allCaps)).isEqualTo(anyChrome); assertThat(getBestMatch(chromeBeta, allCaps)).isEqualTo(chromeBeta); assertThat(getBestMatch(chromeDev, allCaps)).isEqualTo(chromeDev); }
Example 14
Source File: WebDriverTestCase.java From htmlunit with Apache License 2.0 | 5 votes |
private static String getBrowserName(final BrowserVersion browserVersion) { if (browserVersion == BrowserVersion.FIREFOX) { return BrowserType.FIREFOX + '-' + browserVersion.getBrowserVersionNumeric(); } if (browserVersion == BrowserVersion.FIREFOX_68) { return BrowserType.FIREFOX + '-' + browserVersion.getBrowserVersionNumeric(); } else if (browserVersion == BrowserVersion.FIREFOX_60) { return BrowserType.FIREFOX + '-' + browserVersion.getBrowserVersionNumeric(); } if (browserVersion == BrowserVersion.INTERNET_EXPLORER) { return BrowserType.IE; } return BrowserType.CHROME; }
Example 15
Source File: AssumeCapabilityTest.java From hifive-pitalium with Apache License 2.0 | 4 votes |
@CapabilityFilter(browserName = { BrowserType.IE, BrowserType.CHROME }) @Test public void multipleParam() throws Exception { assertAssumed(1); }
Example 16
Source File: AssumeCapabilityTest.java From hifive-pitalium with Apache License 2.0 | 4 votes |
@CapabilityFilter(platform = Platform.WINDOWS, browserName = { BrowserType.FIREFOX, BrowserType.CHROME }) @Test public void platformWindows_browserFirefoxChrome() throws Exception { assertAssumed(0, 1, 2, 5, 6, 7, 8); }
Example 17
Source File: AssumeCapabilityTest.java From hifive-pitalium with Apache License 2.0 | 4 votes |
@CapabilityFilter(browserName = BrowserType.CHROME) @Test public void browserChrome() throws Exception { assertAssumed(0, 1, 2, 3, 4, 5, 7, 8); }
Example 18
Source File: AssumeCapabilityTest.java From hifive-pitalium with Apache License 2.0 | 4 votes |
@CapabilityFilter(browserName = BrowserType.CHROME) @Test public void browserChrome() throws Exception { assertAssumed(0, 1, 2, 3, 4, 5, 7, 8); }
Example 19
Source File: ChromeDriverInfo.java From selenium with Apache License 2.0 | 4 votes |
@Override public Capabilities getCanonicalCapabilities() { return new ImmutableCapabilities(CapabilityType.BROWSER_NAME, BrowserType.CHROME); }
Example 20
Source File: ChromeOptions.java From selenium with Apache License 2.0 | 2 votes |
public ChromeOptions() { super(CapabilityType.BROWSER_NAME, BrowserType.CHROME, CAPABILITY); }