必须学习

导航

appium + java + WebDriverAgent实现IOS app启动

Appium v1.8.1

<dependency>
   <groupId>io.appium</groupId>
   <artifactId>java-client</artifactId>
   <version>6.1.0</version>
</dependency>
<dependency>
   <groupId>org.seleniumhq.selenium</groupId>
   <artifactId>selenium-java</artifactId>
   <version>3.14.0</version>
</dependency>

一、WebDriverAgent下载使用

第一步:git clone https://github.com/facebook/WebDriverAgent.git
第二步:brew install Carthage
第三步:
cd /Users/用户名/Downloads/WebDriverAgent-master(WebDriverAgent-master要根目录)
./Scripts/bootstrap.sh
第四步:用双击WebDriverAgent.xcodeproj会自动打开xcode,进入如下页面
 
执行成功后会在真机上安装成功WebDriverAgentRunner-Runner,这时候就成功一大半了。
java代码,打开IOS APP应用的代码。
public WebDriver iosDriver;
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iphone7");
desiredCapabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.2.1");
desiredCapabilities.setCapability(MobileCapabilityType.APP, “com.xxx.xxx");
desiredCapabilities.setCapability(MobileCapabilityType.UDID, “xx5d57d6a80afxx4d4917ba2af1845ec07c431xx");
URL url = new URL("http://127.0.0.1:4723/wd/hub");
iosDriver = new RemoteWebDriver(url, desiredCapabilities);

posted on 2018-08-09 16:35  必须学习  阅读(2100)  评论(0编辑  收藏  举报