Java 怎么使用Appium启动iOS应用程序

2019年7月29日19:55:46Java 怎么使用Appium启动iOS应用程序已关闭评论 688 1474字阅读4分54秒

1.简介

Java 怎么使用Appium启动iOS应用程序?——请看下文。

2.示例代码

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

import java.net.MalformedURLException;
import java.util.*;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;

public class LaunchApp {
    
    public static void main(String[] args) throws MalformedURLException,
            InterruptedException {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME,
                "Appium");
        capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,
                MobilePlatform.IOS);
        capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,
                "9.1");
        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,
                "Augusta's iPhone6S plus"); 
        capabilities.setCapability("udid",
                "5a127959bdd1b42e47a408b9128ac47fabee698e");
        capabilities.setCapability("app", "com.augusta.poc");
        capabilities.setCapability("safariAllowPopups", false);
        capabilities.setCapability("safariIgnoreFraudWarning", true);
        
        
        IOSDriver driver = new IOSDriver(new URL(
                "http:
        
        
        Thread.sleep(5000);
        Set<String> contextHandlers = driver.getContextHandles();
        for (String contextHandle : contextHandlers) {
            if (contextHandle.contains("WEBVIEW")) {
                driver.context(contextHandle);
            }
        }
        driver.get("http:
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        Thread.sleep(5000);
        driver.quit();
    }
}

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