本文整理汇总了Java中org.openqa.selenium.remote.DesiredCapabilities.setCapability方法的典型用法代码示例。如果您正苦于以下问题:Java DesiredCapabilities.setCapability方法的具体用法?Java DesiredCapabilities.setCapability怎么用?Java DesiredCapabilities.setCapability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openqa.selenium.remote.DesiredCapabilities
的用法示例。
在下文中一共展示了DesiredCapabilities.setCapability方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/apps/");
File app = new File(appDir.getCanonicalPath(), "Financius.v0.18.2.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", ""); // device UID from adb
capabilities.setCapability("platformVersion", "6.0.1"); // android version
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.code44.finance"); // package name
capabilities.setCapability("appWaitActivity", "com.code44.finance.*"); // default activity
capabilities.setCapability("no-reset", "true");
capabilities.setCapability("full-reset", "false");
driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
示例2: newDriverForTest
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private WebDriver newDriverForTest() {
ChromeOptions theOptions = new ChromeOptions();
theOptions.addArguments("headless");
theOptions.addArguments("disable-gpu");
LoggingPreferences theLoggingPreferences = new LoggingPreferences();
theLoggingPreferences.enable(LogType.BROWSER, Level.ALL);
theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences);
DesiredCapabilities theCapabilities = DesiredCapabilities.chrome();
theCapabilities.setCapability(ChromeOptions.CAPABILITY, theOptions);
return new RemoteWebDriver(DRIVERSERVICE.getUrl(), theCapabilities);
}
示例3: createDriver
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
@Override
public WebDriver createDriver(DesiredCapabilities desiredCapabilities) {
desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "6.0.1");
desiredCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Device");
desiredCapabilities.setCapability(AndroidMobileCapabilityType.UNICODE_KEYBOARD, "true");
desiredCapabilities.setCapability(MobileCapabilityType.APP,
Paths.get("../platforms/android/build/outputs/apk/android-debug.apk")
.toAbsolutePath()
.toString());
// capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,
// "com.github.backpaper0.sample.searchusers");
// capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,
// ".MainActivity");
try {
URL url = new URL("http://localhost:4723/wd/hub");
AndroidDriver<WebElement> driver = new AndroidDriver<>(url, desiredCapabilities);
return driver;
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
示例4: getCommonDesiredCapabilities
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private DesiredCapabilities getCommonDesiredCapabilities() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, config.getProperty(KEYS.PLATFORM_NAME.name()));
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, config.getProperty(KEYS.PLATFORM_VERSION.name()));
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, config.getProperty(KEYS.DEVICE_MAKE.name()));
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
capabilities.setCapability(MobileCapabilityType.UDID, config.getProperty(KEYS.ID.name()));
capabilities.setCapability(MobileCapabilityType.FULL_RESET, config.getProperty(KEYS.FULL_RESET.name()));
capabilities.setCapability(MobileCapabilityType.NO_RESET, config.getProperty(KEYS.NO_RESET.name()));
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, config.getProperty(KEYS.APP_PACKAGE.name()));
capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, config.getProperty(KEYS.APP_ACTIVITY.name()));
capabilities.setCapability(AndroidMobileCapabilityType.APP_WAIT_ACTIVITY, config.getProperty(KEYS.APP_WAIT_ACTIVITY.name()));
capabilities.setCapability(AndroidMobileCapabilityType.APP_WAIT_DURATION,60000);
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 600);
capabilities.setCapability("systemPort", Integer.parseInt(config.getProperty(KEYS.APPIUM_PORT.name())));
return capabilities;
}
示例5: createDriver
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
@Override
public WebDriver createDriver(DesiredCapabilities capabilities) {
Map<String, Object> preferences = new Hashtable<>();
preferences.put("profile.default_content_settings.popups", 0);
preferences.put("download.prompt_for_download", "false");
String downloadsPath = System.getProperty("user.home") + "/Downloads";
preferences.put("download.default_directory", loadSystemPropertyOrDefault("fileDownloadPath", downloadsPath));
preferences.put("plugins.plugins_disabled", new String[]{
"Adobe Flash Player", "Chrome PDF Viewer"});
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", preferences);
capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
return new ChromeDriver(capabilities);
}
示例6: generateHtmlUnitDriver
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
/**
* Generates a htmlunit webdriver.
*
* @return
* A htmlunit webdriver
*/
private WebDriver generateHtmlUnitDriver() {
logger.info("Generating HtmlUnit driver...");
final DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
capabilities.setJavascriptEnabled(true);
setLoggingLevel(capabilities);
// Proxy configuration
if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
}
return new HtmlUnitDriver(capabilities);
}
示例7: caps
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private static Capabilities caps(String platform, String browserName, String appiumVersion, String deviceName, String deviceOrientation, String platformVersion) {
try {
DesiredCapabilities capabilities = new DesiredCapabilities();
String buildName = SystemProperties.getCurrentShortDate() + " "
+ WebDriverDiscovery.getBrowserName() + " "
+ WebDriverDiscovery.getBrowserVersion() + " "
+ WebDriverDiscovery.getPlatform();
capabilities.setCapability("appiumVersion", appiumVersion);
capabilities.setCapability("deviceName", deviceName);
capabilities.setCapability("deviceOrientation", deviceOrientation);
capabilities.setCapability("browserName", browserName);
capabilities.setCapability("platformName", platform);
capabilities.setCapability("platformVersion", platformVersion);
capabilities.setCapability("sauce-advisor", false);
capabilities.setCapability("record-video", true);
capabilities.setCapability("record-screenshots", true);
capabilities.setCapability("build", buildName);
LOG.info("capabilities : " + capabilities.asMap().toString());
return capabilities;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例8: startIOSSpy
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private static void startIOSSpy() {
try {
if (wd == null) {
DesiredCapabilities capabilities = new DesiredCapabilities();
for (String key : caps.keySet()) {
capabilities.setCapability(key, caps.get(key));
}
wd = new IOSDriver(new URL(url), capabilities);
}
} catch (Exception ex) {
Logger.getLogger(IOSpy.class.getName()).log(Level.SEVERE, null, ex);
Notification.show("Couldn't Connect to Device/Simulator Check Settings/Appium Logs");
}
}
示例9: firefox
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
/**
* 火狐浏览器配置
*/
private void firefox()
{
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setCapability("marionette", true);
engineCapMap.put(DRIVER_FIREFOX, capability);
}
示例10: get32IEDriver
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
public static WebDriver get32IEDriver()
{
String path = System.getProperty("user.dir") + "\\Drivers\\IEDriverServer32.exe";
System.setProperty("webdriver.ie.driver", path);
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
return new InternetExplorerDriver(caps);
}
示例11: getFFUAECaps
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private static DesiredCapabilities getFFUAECaps(DesiredCapabilities caps, Emulator emulator) {
FirefoxProfile profile = new FirefoxProfile();
if (!emulator.getUserAgent().trim().isEmpty()) {
profile.setPreference("general.useragent.override", emulator.getUserAgent());
}
caps.setCapability(FirefoxDriver.PROFILE, profile);
return caps;
}
示例12: createAndroidDriver
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
/**
* Android app测试
*
* @param noReset
*/
private void createAndroidDriver(Boolean noReset) {
capabilities = new DesiredCapabilities();
// app is absolute path
capabilities.setCapability("app",
String.join(File.separator, System.getProperty("user.dir"), property.getProperty("app")));
capabilities.setCapability("platformName", property.getProperty("platformName"));
capabilities.setCapability("platformVersion", property.getProperty("platformVersion"));
// On Android this capability is currently ignored, though it remains required.
capabilities.setCapability("deviceName", property.getProperty("deviceName"));
capabilities.setCapability("appPackage", property.getProperty("appPackage"));
capabilities.setCapability("appActivity", property.getProperty("appActivity"));
// physical device
capabilities.setCapability("udid", property.getProperty("udid"));
// debug时,等待时间调大点!!
capabilities.setCapability("newCommandTimeout", property.getProperty("newCommandTimeout"));
capabilities.setCapability("noReset", noReset); // 不卸载、不重装
capabilities.setCapability("noSign", "true");
// 重置输入法,并且设置可以中文输入
capabilities.setCapability("unicodeKeyboard", "True");
capabilities.setCapability("resetKeyboard", "True");
try {
driver = new AndroidDriver<MobileElement>(new URL(property.getProperty("remote.address")), capabilities);
} catch (Exception e) {
e.printStackTrace();
AssertUtil.fail("初始化对象失败,e = " + e.getMessage());
}
}
示例13: getDefaultDesiredCapabilities
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
public static DesiredCapabilities getDefaultDesiredCapabilities() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("acceptSslCerts", true);
capabilities.setCapability("takesScreenshot", true);
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, asList("--ignore-ssl-errors=true"));
LoggingPreferences loggingPreferences = new LoggingPreferences();
loggingPreferences.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences);
return capabilities;
}
示例14: getEdgeDriver
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
public static WebDriver getEdgeDriver()
{
String path = System.getProperty("user.dir") + "\\Drivers\\EdgeWebDriver.exe";
System.setProperty("webdriver.ie.driver", path);
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
return new InternetExplorerDriver(caps);
}
示例15: test
import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
@Ignore
@Test
public void test() throws IOException {
Map<String, String> baseState = new HashMap<>();
baseState.put("type", "MOBILE");
baseState.put("connectionString", "platformName=Android;app=C:\\apps\\InsuranceMobile.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appdriver-basestate", baseState);
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:8080"), capabilities);
String title = driver.getTitle();
assertEquals("", title); // TODO: Maybe we find something to use as the
// title?
WebElement email = driver
.findElement(By.xpath("//MobileTextField[@resource-id='silktest.insurancemobile:id/email']"));
email.sendKeys("test");
assertEquals("test", email.getText());
email.clear();
assertEquals("", email.getText());
email.sendKeys("[email protected]");
driver.findElement(By.xpath("//MobileTextField[@resource-id='silktest.insurancemobile:id/password']"))
.sendKeys("john");
driver.findElement(By.xpath("//MobileButton[@resource-id='silktest.insurancemobile:id/log_in_button']"))
.click();
driver.findElement(By.xpath("//MobileObject[@content-desc='drawer_open']")).click();
driver.findElement(By.xpath("//MobileObject[@caption='Logout']")).click();
driver.quit();
}