Java 类org.openqa.selenium.MutableCapabilities 实例源码
项目:Selenium-Foundation
文件:SeleniumConfigTest.java
@Test
public void testNodeConfig() {
SeleniumConfig config = SeleniumConfig.getConfig();
GridNodeConfiguration nodeConfig = config.getNodeConfig();
assertNotNull(nodeConfig);
assertEquals(nodeConfig.role, "node");
boolean hasPhantomJS = false;
for (MutableCapabilities capability : nodeConfig.capabilities) {
if ("phantomjs".equals(capability.getBrowserName())) {
hasPhantomJS = true;
break;
}
}
assertTrue(hasPhantomJS);
}
项目:selenium-jupiter
文件:ChromeDriverHandler.java
@Override
public MutableCapabilities getOptions(Parameter parameter,
Optional<Object> testInstance)
throws IOException, IllegalAccessException {
ChromeOptions chromeOptions = new ChromeOptions();
// @Arguments
Arguments arguments = parameter.getAnnotation(Arguments.class);
if (arguments != null) {
stream(arguments.value()).forEach(chromeOptions::addArguments);
}
// @Extensions
Extensions extensions = parameter.getAnnotation(Extensions.class);
if (extensions != null) {
for (String extension : extensions.value()) {
chromeOptions.addExtensions(getExtension(extension));
}
}
// @Binary
Binary binary = parameter.getAnnotation(Binary.class);
if (binary != null) {
chromeOptions.setBinary(binary.value());
}
// @Options
Object optionsFromAnnotatedField = annotationsReader
.getOptionsFromAnnotatedField(testInstance, Options.class);
if (optionsFromAnnotatedField != null) {
chromeOptions = ((ChromeOptions) optionsFromAnnotatedField)
.merge(chromeOptions);
}
return chromeOptions;
}
项目:selenium-jupiter
文件:DockerDriverHandler.java
private DesiredCapabilities getCapabilities(BrowserType browser,
boolean enableVnc) throws IllegalAccessException, IOException {
DesiredCapabilities capabilities = browser.getCapabilities();
if (enableVnc) {
capabilities.setCapability("enableVNC", true);
capabilities.setCapability("screenResolution",
getString("sel.jup.vnc.screen.resolution"));
}
if (recording) {
capabilities.setCapability("enableVideo", true);
capabilities.setCapability("videoScreenSize",
getString("sel.jup.recording.video.screen.size"));
capabilities.setCapability("videoFrameRate",
getInt("sel.jup.recording.video.frame.rate"));
}
Optional<Capabilities> optionalCapabilities = annotationsReader
.getCapabilities(parameter, testInstance);
MutableCapabilities options = browser.getDriverHandler()
.getOptions(parameter, testInstance);
// Due to bug in operablink the binary path must be set
if (browser == OPERA) {
((OperaOptions) options).setBinary("/usr/bin/opera");
}
if (optionalCapabilities.isPresent()) {
options.merge(optionalCapabilities.get());
}
capabilities.setCapability(browser.getOptionsKey(), options);
log.trace("Using capabilities for Docker browser {}", capabilities);
return capabilities;
}
项目:minium
文件:WebDriverFactory.java
private Capabilities browserSpecificCapabilities(WebDriverProperties webDriverProperties) throws IOException {
ChromeOptionsProperties chromeProperties = webDriverProperties.getChromeOptions();
if (chromeProperties != null) return chromeCapabilities(chromeProperties);
FirefoxProfileProperties firefoxProperties = webDriverProperties.getFirefoxProfile();
if (firefoxProperties != null) return firefoxCapabilities(firefoxProperties);
return new MutableCapabilities();
}
项目:givemeadriver
文件:PhantomJSCapabilitiesConverter.java
private void addToCapabilitiesIfNoEmptyValue(MutableCapabilities capabilities, String key, String value) {
if (isNotEmpty(value)) {
capabilities.setCapability(key, value);
}
}
项目:selenium-jupiter
文件:FirefoxDriverHandler.java
@Override
public MutableCapabilities getOptions(Parameter parameter,
Optional<Object> testInstance)
throws IOException, IllegalAccessException {
FirefoxOptions firefoxOptions = new FirefoxOptions();
// @Arguments
Arguments arguments = parameter.getAnnotation(Arguments.class);
if (arguments != null) {
stream(arguments.value()).forEach(firefoxOptions::addArguments);
}
// @Extensions
Extensions extensions = parameter.getAnnotation(Extensions.class);
if (extensions != null) {
for (String extension : extensions.value()) {
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(getExtension(extension));
firefoxOptions.setProfile(firefoxProfile);
}
}
// @Binary
Binary binary = parameter.getAnnotation(Binary.class);
if (binary != null) {
firefoxOptions.setBinary(binary.value());
}
// @Preferences
managePreferences(parameter, firefoxOptions);
// @Options
Object optionsFromAnnotatedField = annotationsReader
.getOptionsFromAnnotatedField(testInstance, Options.class);
if (optionsFromAnnotatedField != null) {
firefoxOptions = ((FirefoxOptions) optionsFromAnnotatedField)
.merge(firefoxOptions);
}
return firefoxOptions;
}
项目:selenium-jupiter
文件:DriverHandler.java
public MutableCapabilities getOptions(Parameter parameter,
Optional<Object> testInstance)
throws IOException, IllegalAccessException {
throw new IllegalAccessException("Not implemented");
}