Java Code Examples for org.openqa.selenium.remote.BrowserType#FIREFOX

The following examples show how to use org.openqa.selenium.remote.BrowserType#FIREFOX . 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: BrowserSpecs.java    From KITE with Apache License 2.0 6 votes vote down vote up
/**
 * 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 2
Source File: CapabilitiesComparatorTest.java    From selenium with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: WebDriverTestCase.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
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 4
Source File: SeleniumEphemeral.java    From ephemerals with MIT License 5 votes vote down vote up
@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 5
Source File: BrowserWebDriverContainer.java    From testcontainers-java with MIT License 5 votes vote down vote up
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 6
Source File: AssumeCapabilityTest.java    From hifive-pitalium with Apache License 2.0 5 votes vote down vote up
@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 7
Source File: WebProxyJsonRenderer.java    From selenium-api with MIT License 5 votes vote down vote up
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 8
Source File: AssumeCapabilityTest.java    From hifive-pitalium with Apache License 2.0 4 votes vote down vote up
@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 9
Source File: GeckoDriverInfo.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public Capabilities getCanonicalCapabilities() {
  return new ImmutableCapabilities(BROWSER_NAME, BrowserType.FIREFOX);
}
 
Example 10
Source File: XpiDriverInfo.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public Capabilities getCanonicalCapabilities() {
  return new ImmutableCapabilities(BROWSER_NAME, BrowserType.FIREFOX, MARIONETTE, true);
}