capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability("platformVersion", "10.0");
capabilities.setCapability("deviceName", "iPhone 6");
运行testUIComputation
方法。可以看到模拟器启动了,但是之后会遇到Carthage找不到的问题
[XCUITest] Carthage not found. Install using
brew install carthage
装上之后
Original error: Command '/bin/bash Scripts/bootstrap.sh -d'
官方Issues中找到了答案,WebDriverAgent缺少webpack。使用npm i -g webpack
安装就好。PS:和之前一样使用淘宝源或者挂一个代理。
完成了以上步骤之后,你就能看到你的Test在模拟器中自动运行,随着Terminal大量的log输出,测试结果也成功返回到Java的Client,在IDEA中看到执行结果,PASS!到此为止,第一个自动化测试被执行成功了~
我们以java代码driver.findElements(By.className("UIATextField"))
找到textField数组的过程为例子,去分析一下log,看看一次交互式怎么进行的。
// client ----http----> server
[HTTP] --> POST /wd/hub/session/94f7526c-94ba-4ece-8740-d94bd3d4f50f/elements {"using":"class name","value":"UIATextField"}
[MJSONWP] Calling AppiumDriver.findElements() with args: ["class name","UIATextField","94f7526c-94ba-4ece-8740-d94bd3d4f50f"]
[debug] [XCUITest] Executing command 'findElements'
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, accessibility id
[XCUITest] Rewrote incoming selector from 'UIATextField' to 'XCUIElementTypeTextField' to match XCUI type. You should consider updating your tests to use the new selectors directly
[debug] [BaseDriver] Waiting up to 0 ms for condition
// server ----http----> device
[JSONWP Proxy] Proxying [POST /elements] to [POST http://localhost:8100/session/79CBBB84-DB6E-48BA-B79F-91539E1E4708/elements] with body: {"using":"class name","value":"XCUIElementTypeTextField"}
// device ----http----> server
[JSONWP Proxy] Got response with status 200: {"value":[{"ELEMENT":"1A29AE60-5433-4B52-83F8-B4E2C794972E","type":"XCUIElementTypeTextField","label":"TextField1"},{"ELEMENT":"575EE2C2-4AFF-4320-B4D0-C30F59410DA9","type":"XCUIElementTypeTextField","label":"TextField2"}],"sessionId":"79CBBB84-DB6E-48BA-B79F-91539E1E4708"
原文转自:http://www.jianshu.com/p/aae160cb9cc4