當前位置: 首頁>>代碼示例>>Java>>正文


Java DesiredCapabilities.setCapability方法代碼示例

本文整理匯總了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);
  
  }
 
開發者ID:ark-konopacki,項目名稱:appium_tutorial,代碼行數:19,代碼來源:BaseDriver.java

示例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);
}
 
開發者ID:mirkosertic,項目名稱:Bytecoder,代碼行數:15,代碼來源:BytecoderUnitTestRunner.java

示例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);
    }
}
 
開發者ID:backpaper0,項目名稱:cordova-vue-sample,代碼行數:26,代碼來源:AndroidDriverProvider.java

示例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;
}
 
開發者ID:anandbagmar,項目名稱:cucumber-jvm-appium-infra,代碼行數:18,代碼來源:5.1 Hooks.java

示例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);
}
 
開發者ID:alfa-laboratory,項目名稱:akita-testing-template,代碼行數:18,代碼來源:AkitaChromeDriverProvider.java

示例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);
}
 
開發者ID:NoraUi,項目名稱:NoraUi,代碼行數:22,代碼來源:DriverFactory.java

示例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;
}
 
開發者ID:usman-h,項目名稱:Habanero,代碼行數:26,代碼來源:SauceLabsDriver.java

示例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");
    }
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:15,代碼來源:IOSpy.java

示例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);
}
 
開發者ID:LinuxSuRen,項目名稱:phoenix.webui.framework,代碼行數:10,代碼來源:CapabilityConfig.java

示例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);
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:9,代碼來源:SeleniumTestUtilities.java

示例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;
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:9,代碼來源:WebDriverFactory.java

示例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());
	}
}
 
開發者ID:quanqinle,項目名稱:WebAndAppUITesting,代碼行數:36,代碼來源:DriverFactory.java

示例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;
}
 
開發者ID:robevansuk,項目名稱:delay-repay-bot,代碼行數:12,代碼來源:PhantomJSTest.java

示例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);
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:9,代碼來源:SeleniumTestUtilities.java

示例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();
}
 
開發者ID:MicroFocus,項目名稱:SilkAppDriver,代碼行數:38,代碼來源:MobileTests.java


注:本文中的org.openqa.selenium.remote.DesiredCapabilities.setCapability方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。