这看出setValue命令,包含几个步骤:检查是否打开键盘、获取输入框、弹出键盘、输入框赋值,每一个步骤都会和Device通讯。
看发送数据
/session/94f7526c-94ba-4ece-8740-d94bd3d4f50f/element/1A29AE60-5433-4B52-83F8-B4E2C794972E/value {"id":"1A29AE60-5433-4B52-83F8-B4E2C794972E","value":["1"]}
session/94f7526c-94ba-4ece-8740-d94bd3d4f50f 这个指定了当前这个case的唯一id,在第一次通信时确立。由于第一次通信比较复杂,在最后会讲到。之后是id为1A29AE60-5433-4B52-83F8-B4E2C794972E 的Element,刚好是上一次请求列表的第一个元素,表明这次是对这个元素做操作。再看value,是一个json,定义的刚好是这个Eelemet和它的值,这些就是自动化统一接口的格式,一个简单命令的定义。
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"app":"/Users/zhiyu.zhao/Desktop/appiumTest/sample-code/sample-code/examples/java/junit/../../../apps/TestApp/build/release-iphonesimulator/TestApp.app","automationName":"XCUITest","platformName":"iOS","deviceName":"iPhone 6","platformVersion":"10.0"}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"/Users/zhiyu.zhao/Desktop/appiumTest/sample-code/sample-code/examples/java/junit/../../../apps/TestApp/build/release-iphonesimulator/TestApp.app","automationName":"XCUITest","platformName":"iOS","deviceName":"iPhone 6","platformVersion":"...
[Appium] Creating new XCUITestDriver session
[Appium] Capabilities:
[Appium] app: '/Users/zhiyu.zhao/Desktop/appiumTest/sample-code/sample-code/examples/java/junit/../../../apps/TestApp/build/release-iphonesimulator/TestApp.app'
[Appium] automationName: 'XCUITest'
[Appium] platformName: 'iOS'
[Appium] deviceName: 'iPhone 6'
[Appium] platformVersion: '10.0'
[debug] [XCUITest] XCUITestDriver version: 2.0.33
[BaseDriver] Session created with session id: 94f7526c-94ba-4ece-8740-d94bd3d4f50f
[debug] [XCUITest] Xcode version set to '8.0'
[debug] [XCUITest] iOS SDK Version set to '10.0'
[iOSSim] Constructing iOS simulator for Xcode version 8.0 with udid 'B9747B0B-C664-4C44-A651-9C3D8F7A980A'
// 开启模拟器
[XCUITest] Determining device to run tests on: udid: 'B9747B0B-C664-4C44-A651-9C3D8F7A980A', real device: false
[BaseDriver] Using local app '/Users/zhiyu.zhao/Desktop/appiumTest/sample-code/sample-code/examples/java/junit/../../../apps/TestApp/build/release-iphonesimulator/TestApp.app'
[debug] [XCUITest] Checking whether app '/Users/zhiyu.zhao/Desktop/appiumTest/sample-code/sample-code/examples/java/junit/../../../apps/TestApp/build/release-iphonesimulator/TestApp.app' is actually present
[debug] [XCUITest] App is present
[debug] [ios-app-utils] Getting bundle ID from app '/Users/zhiyu.zhao/Desktop/appiumTest/sample-code/sample-code/examples/java/junit/../../../apps/TestApp/build/release-iphonesimulator/TestApp.app': 'io.appium.TestApp'
[debug] [iOSLog] Starting iOS 10.0 simulator log capture
[debug] [iOSLog] System log path: /Users/zhiyu.zhao/Library/Logs/CoreSimulator/B9747B0B-C664-4C44-A651-9C3D8F7A980A/system.log
[XCUITest] Setting up simulator
[debug] [iOS] No reason to set locale
[debug] [iOS] No iOS / app preferences to set
[XCUITest] Simulator with udid 'B9747B0B-C664-4C44-A651-9C3D8F7A980A' not booted. Booting up now
[debug] [iOSSim] Killing all iOS Simulators
zhiyu.zhao@999999999:~|⇒ [iOSSim] Starting simulator with command: open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID B9747B0B-C664-4C44-A651-9C3D8F7A980A
[iOSSim] Tailing simulator logs until we encounter the string "SMS Plugin initialized"
[iOSSim] We will time out after 60000ms
[debug] [iOSSim] Waiting an extra 10000ms for the simulator to really finish booting
[debug] [iOSSim] Done waiting extra time for simulator
[iOSSim] Simulator booted in 26076ms
// 安装TestApp、开启WebDriverAgent
[debug] [XCUITest] Installing app '/Users/zhiyu.zhao/Desktop/appiumTest/sample-code/sample-code/examples/java/junit/../../../apps/TestApp/build/release-iphonesimulator/TestApp.app' on device
[XCUITest] Using default agent: /usr/local/lib/node
原文转自:http://www.jianshu.com/p/aae160cb9cc4