Java 怎么使用Appium的真实设备上的Safari

2019年7月29日19:55:41Java 怎么使用Appium的真实设备上的Safari已关闭评论 426 1459字阅读4分51秒

1.简介

Java 怎么使用Appium的真实设备上的Safari?——请看下文。

2.示例代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */
package com.augusta.SafariOnRealDevice;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.ios.IOSDriver;

public class IOSSwitchsTest {
    public static void main(String[] args) throws MalformedURLException {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("automationName", "Appium");
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("platformVersion", "9.2.1");
        capabilities.setCapability("deviceName", "iPhone"); 
        capabilities.setCapability("platformVersion", "9.1");
        capabilities.setCapability("deviceName",
                "Augusta?s iPhone6S plus"); 

        capabilities
                .setCapability(
                        "app",
                        "/Users/administrator/Library/Developer/Xcode/DerivedData/UICatalog-etygmeejalybcbeaczwvsdflvftm/Build/Products/Debug-iphoneos/UICatalog.app");
        capabilities.setCapability("bundleId", "com.augusta.test"); 
        capabilities.setCapability("udid","your id");
        IOSDriver driver = new IOSDriver(new URL(
                "http:
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        driver.scrollTo("Switches").click();
        if (((WebElement) driver.findElements(By.className("UIASwitch"))
                .get(0)).getAttribute("value").equals("1"))
            ;
        {
            ((WebElement) driver.findElements(By.className("UIASwitch"))
                    .get(0)).click();
        }

        driver.quit();
    }
}

 
继续阅读
编程十万个怎么办