capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability("platformVersion", "10.0");
capabilities.setCapability("deviceName", "iPhone 6");
運行testUIComputation
方法??梢钥吹侥M器啟動了,但是之后會遇到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