本文整理汇总了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();
}
示例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");
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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());
}
示例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 //
);
}
示例8: multipleParam
@CapabilityFilter(browserName = { BrowserType.IE, BrowserType.CHROME })
@Test
public void multipleParam() throws Exception {
assertAssumed(1);
}
示例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);
}
示例10: browserChrome
@CapabilityFilter(browserName = BrowserType.CHROME)
@Test
public void browserChrome() throws Exception {
assertAssumed(0, 1, 2, 3, 4, 5, 7, 8);
}