本文整理汇总了Java中org.openqa.selenium.remote.DesiredCapabilities.setVersion方法的典型用法代码示例。如果您正苦于以下问题:Java DesiredCapabilities.setVersion方法的具体用法?Java DesiredCapabilities.setVersion怎么用?Java DesiredCapabilities.setVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openqa.selenium.remote.DesiredCapabilities
的用法示例。
在下文中一共展示了DesiredCapabilities.setVersion方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defaultConfiguration
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
default Capabilities defaultConfiguration(final XmlConfig config) {
final DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName(config.getBrowser());
capabilities.setVersion(config.getVersion());
capabilities.setPlatform(config.getPlatform());
return capabilities;
}
示例2: instantiateWebDriver
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private void instantiateWebDriver( DesiredCapabilities desiredCapabilities ) throws MalformedURLException
{
System.out.println( String.format( "Current Operating System : {%s}"
, operatingSystem ) );
System.out.println( String.format( "Current System Architecture : {%s}"
, systemArchitecture ) );
System.out.println( String.format( "Current Browser : {%s}\n"
, driverType ) );
if( useRemoteWebDriver )
{
URL seleniumGridURL = new URL( System.getProperty( "gridURL" ) );
System.out.println( "seleniumGridURL = " + seleniumGridURL );
String desiredBrowserVersion = System.getProperty( "desiredBrowserVersion" );
String desiredPlatform = System.getProperty( "desiredPlatform" );
if( ( null != desiredPlatform ) && desiredPlatform.isEmpty() )
{
desiredCapabilities.setPlatform( Platform.valueOf( desiredPlatform ) );
}
if( null != desiredBrowserVersion && desiredBrowserVersion.isEmpty() )
{
desiredCapabilities.setVersion( desiredBrowserVersion );
}
driver = new RemoteWebDriver( seleniumGridURL, desiredCapabilities );
} else
{
driver = selectedDriverType.getWebDriverObject( desiredCapabilities );
}
}
示例3: create
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private static WebDriver create(RunContext context, ProjectSettings settings, Boolean isGrid, String remoteUrl) {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setPlatform(context.Platform);
if (!context.BrowserVersion.equalsIgnoreCase("default")) {
caps.setVersion(context.BrowserVersion);
}
caps.merge(getCapability(context.BrowserName, settings));
return create(context.BrowserName, caps, settings, isGrid, remoteUrl);
}
示例4: createSessionWithDefaultCapabilities
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
public void createSessionWithDefaultCapabilities() {
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setVersion("");
driver = new JavaDriver(desiredCapabilities, desiredCapabilities);
}
示例5: Crawler
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
public Crawler(final String courseName) {
this.courseName = courseName;
DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
capabilities.setVersion(BrowserType.FIREFOX);
driver = new HtmlUnitDriver(capabilities);
}
示例6: createCapabilities
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
/**
* Creates a Capabilities object based on the given Browser object.
*
* @param browser Browser
* @param testName name for individual test case
* @return Capabilities
*/
private static Capabilities createCapabilities(Browser browser, String testName) {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName(browser.getBrowserName());
if (browser.getVersion() != null)
capabilities.setVersion(browser.getVersion());
if (browser.getPlatform() != null)
capabilities.setCapability("platform", browser.getPlatform());
// Remote test identifier
capabilities.setCapability("name", testName);
switch (browser.getBrowserName()) {
case "chrome":
// capabilities = DesiredCapabilities.chrome();
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("use-fake-ui-for-media-stream");
chromeOptions.addArguments("use-fake-device-for-media-stream");
/*
* chromeOptions.addArguments("no-sandbox"); chromeOptions.addArguments("disable-infobars");
* chromeOptions.addArguments("test-type=browser");
* chromeOptions.addArguments("disable-extensions");
* chromeOptions.addArguments("--js-flags=--expose-gc");
* chromeOptions.addArguments("--disable-default-apps");
* chromeOptions.addArguments("--disable-popup-blocking");
* chromeOptions.addArguments("--enable-precise-memory-info");
*/
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
break;
case "firefox":
// capabilities = DesiredCapabilities.firefox();
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("media.navigator.streams.fake", true);
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(firefoxProfile);
capabilities.merge(firefoxOptions.toCapabilities());
/*
* capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
*/
break;
case "MicrosoftEdge":
// capabilities = DesiredCapabilities.edge();
capabilities.setCapability("avoidProxy", true);
break;
case "safari":
// capabilities = DesiredCapabilities.safari();
SafariOptions options = new SafariOptions();
options.setUseTechnologyPreview(true);
capabilities.setCapability(SafariOptions.CAPABILITY, options);
break;
}
// Capabilities for mobile browsers
Mobile mobile = browser.getMobile();
if (mobile != null) {
capabilities.setCapability("deviceName", mobile.getDeviceName());
capabilities.setCapability("platformName", mobile.getPlatformName());
capabilities.setCapability("platformVersion", mobile.getPlatformVersion());
if (mobile.getPlatformName().equalsIgnoreCase("iOS")) {
capabilities.setCapability("automationName", "XCUITest");
} else {
capabilities.setCapability("autoGrantPermissions", true);
capabilities.setCapability("noReset", true);
}
}
return capabilities;
}