当前位置: 首页>>代码示例>>Java>>正文


Java BrowserType.CHROME属性代码示例

本文整理汇总了Java中org.openqa.selenium.remote.BrowserType.CHROME属性的典型用法代码示例。如果您正苦于以下问题:Java BrowserType.CHROME属性的具体用法?Java BrowserType.CHROME怎么用?Java BrowserType.CHROME使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.openqa.selenium.remote.BrowserType的用法示例。


在下文中一共展示了BrowserType.CHROME属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDeploymentUnit

@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();

}
 
开发者ID:LivePersonInc,项目名称:ephemerals,代码行数:39,代码来源:SeleniumEphemeral.java

示例2: getImageForCapabilities

public static String getImageForCapabilities(DesiredCapabilities desiredCapabilities) {

        String seleniumVersion = SeleniumUtils.determineClasspathSeleniumVersion();

        String browserName = desiredCapabilities.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");
        }
    }
 
开发者ID:testcontainers,项目名称:testcontainers-java,代码行数:14,代码来源:BrowserWebDriverContainer.java

示例3: multipleFilters

@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);
}
 
开发者ID:hifive,项目名称:hifive-pitalium,代码行数:7,代码来源:AssumeCapabilityTest.java

示例4: create

public static Actions create(final WebDriver webDriver) {
    switch (getBrowserName(webDriver)) {
    case BrowserType.CHROME:
        return new ChromeActions(webDriver);
    case BrowserType.IE:
        return new InternetExplorerActions(webDriver);
    case BrowserType.FIREFOX:
    case BrowserType.SAFARI:
        return new SyntheticActions(webDriver);
    default:
        return new DefaultActions(webDriver);
    }
}
 
开发者ID:MagenTys,项目名称:cinnamon,代码行数:13,代码来源:ActionsFactory.java

示例5: create

public WebDriver create(WebDriverProperties webDriverProperties) throws IOException {
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities(webDriverProperties.getDesiredCapabilities());
    desiredCapabilities.merge(browserSpecificCapabilities(webDriverProperties));

    WebDriver webDriver = null;
    if (webDriverProperties.getUrl() != null) {
        RemoteWebDriver remoteDriver = new RemoteWebDriver(webDriverProperties.getUrl(), desiredCapabilities);
        remoteDriver.setFileDetector(new LocalFileDetector());
        webDriver = remoteDriver;
    } else {
        String browserName = desiredCapabilities == null ? null : desiredCapabilities.getBrowserName();
        if (Strings.isNullOrEmpty(browserName)) browserName = BrowserType.CHROME;
        webDriver = WebDriverType.typeFor(browserName).create(this, desiredCapabilities);
    }

    WindowProperties window = webDriverProperties.getWindow();
    if (window != null) {
        DimensionProperties size = window.getSize();
        PointProperties position = window.getPosition();
        if (size != null) webDriver.manage().window().setSize(new Dimension(size.getWidth(), size.getHeight()));
        if (position != null) webDriver.manage().window().setPosition(new Point(position.getX(), position.getY()));
        if (window.isMaximized()) {
            webDriver.manage().window().maximize();
        }
    }

    webDriver = webDriver instanceof TakesScreenshot ? webDriver : new Augmenter().augment(webDriver);
    for (WebDriverTransformer transformer : driverServices.getWebDriverTranformers()) webDriver = transformer.transform(webDriver);
    return webDriverProperties.isStateful() ? new StatefulWebDriver(webDriver) : webDriver;
}
 
开发者ID:viltgroup,项目名称:minium,代码行数:30,代码来源:WebDriverFactory.java

示例6: testWebElementsDriverProperties

@Test
public void testWebElementsDriverProperties() throws MalformedURLException {
    DesiredCapabilities expectedDesiredCapabilities = new DesiredCapabilities(BrowserType.CHROME, "39.0", Platform.LINUX);
    assertThat(new DesiredCapabilities(webDriverProperties.getDesiredCapabilities()), equalTo(expectedDesiredCapabilities));
    assertThat(webDriverProperties.isStateful(), equalTo(true));
    assertThat(webDriverProperties.getUrl(), equalTo(new URL("http://localhost:4444/wd/hub")));
    assertThat(webDriverProperties.getWindow().getSize(), equalTo(new DimensionProperties(1280, 1024)));
    assertThat(webDriverProperties.getWindow().getPosition(), nullValue());
}
 
开发者ID:viltgroup,项目名称:minium,代码行数:9,代码来源:WebDriverConfigurationTest.java

示例7: ChromeWebDriverFactory

public ChromeWebDriverFactory() {
  super( //
      BrowserType.CHROME, //
      (targetDirectory) -> {
        final String extension = getExecutableExtension(true);
        final Pattern executablePattern =
            Pattern.compile("chromedriver-(?<version>.*)" + extension);
        final File[] files =
            targetDirectory.listFiles(new PatternFilenameFilter(executablePattern));
        if (files == null || files.length != 1) {
          return Optional.empty();
        }
        final File executable = files[0];
        final Matcher executableMatcher = executablePattern.matcher(executable.getName());
        if (!executableMatcher.find()) {
          throw new IllegalStateException(
              String.format("Unable to determine version of executable %s", executable));
        }
        final String version = executableMatcher.group("version");
        return Optional
            .of(new DownloadWebDriverExecutable.WebDriverExecutable(executable, version));
      }, //
      () -> getString(LATEST_RELEASE_URL), //
      (version, targetDirectory) -> {
        final String system;
        if (SystemUtils.IS_OS_WINDOWS) {
          system = "win32";
        } else if (SystemUtils.IS_OS_MAC) {
          system = "mac64";
        } else if (SystemUtils.IS_OS_LINUX) {
          final StringBuilder linuxBuilder = new StringBuilder("linux");
          // TODO this property does not reflect the OS architecture, it is the VM`s "bitness"
          if (SystemUtils.OS_ARCH.contains("64")) {
            linuxBuilder.append("64");
          } else {
            linuxBuilder.append("32");
          }
          system = linuxBuilder.toString();
        } else {
          throw new UnsupportedOperationException(
              String.format("Unsupported operation system: %s %s", SystemUtils.OS_NAME,
                  SystemUtils.OS_VERSION));
        }
        LOGGER.debug("System '{}' detected.", system);
        final String downloadUrl =
            DOWNLOAD_URL + String.format("/%s/chromedriver_%s.zip", version, system);
        LOGGER.debug("Download chromedriver from {}", downloadUrl);
        downloadZipAndExtract(downloadUrl, targetDirectory);
        final File chromeDriverFile = new File(targetDirectory,
            String.format("chromedriver%s", getExecutableExtension(false)));
        final File chromeDriverFileWithVersion = new File(targetDirectory,
            String.format("chromedriver-%s%s", version, getExecutableExtension(false)));
        if (!chromeDriverFile.renameTo(chromeDriverFileWithVersion)) {
          throw new RuntimeException();
        }
        if (!chromeDriverFileWithVersion.setExecutable(true, false)) {
          throw new RuntimeException();
        }
        return new DownloadWebDriverExecutable.WebDriverExecutable(chromeDriverFileWithVersion,
            version);
      }, //
      ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY //
  );
}
 
开发者ID:klaushauschild1984,项目名称:selenium-toys,代码行数:64,代码来源:ChromeWebDriverFactory.java

示例8: multipleParam

@CapabilityFilter(browserName = { BrowserType.IE, BrowserType.CHROME })
@Test
public void multipleParam() throws Exception {
	assertAssumed(1);
}
 
开发者ID:hifive,项目名称:hifive-pitalium,代码行数:5,代码来源:AssumeCapabilityTest.java

示例9: platformWindows_browserFirefoxChrome

@CapabilityFilter(platform = Platform.WINDOWS, browserName = { BrowserType.FIREFOX, BrowserType.CHROME })
@Test
public void platformWindows_browserFirefoxChrome() throws Exception {
	assertAssumed(0, 1, 2, 5, 6, 7, 8);
}
 
开发者ID:hifive,项目名称:hifive-pitalium,代码行数:5,代码来源:AssumeCapabilityTest.java

示例10: browserChrome

@CapabilityFilter(browserName = BrowserType.CHROME)
@Test
public void browserChrome() throws Exception {
	assertAssumed(0, 1, 2, 3, 4, 5, 7, 8);
}
 
开发者ID:hifive,项目名称:hifive-pitalium,代码行数:5,代码来源:AssumeCapabilityTest.java


注:本文中的org.openqa.selenium.remote.BrowserType.CHROME属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。