@luyi0824 你在模拟器上能运行么? xcode 必须 5.0.2 或者以上
@luyi0824 你没按我的步骤啊。。。 bundle id 不对
#5 楼 @luyi0824 我重启了下 mac 后, 可以了 运行成功。
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"sessionId":null,"desiredCapabilities":{"device":"iPhone Simulator","platform":"Mac","browserName":"","version":"6.0","app":"io.appium.TestApp"}}
info: App is an iOS bundle, will attempt to run as pre-existing
info: Creating new appium session bcc46555-24e6-46b0-b725-d1d4b462af08
info: Removing any remaining instruments sockets
info: Cleaned up instruments socket /tmp/instruments_sock
info: Cleaning up any tracedirs
info: No tracedirs to clean up
info: Localizable.strings is not currently supported when using real devices.
info: Not setting device type since we're connected to a device
info: Starting iOS device log capture via idevicesyslog
debug: Real device specified but no ipa, assuming bundle ID is on device
debug: Creating instruments
info: instruments is: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
info: [INSTSERVER] Instruments socket server started at /tmp/instruments_sock
info: Attempting to run app on real device with UDID 45f082689dbaebb0ffa3620b3ae22ad9faff9a30
info: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -w 45f082689dbaebb0ffa3620b3ae22ad9faff9a30 io.appium.TestApp -e UIASCRIPT /usr/local/lib/node_modules/appium/lib/devices/ios/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments/
info: And extra without-delay env: {}
info: And launch timeout: 90000ms
info: [INSTSERVER] Instruments is ready to receive commands
info: Instruments launched. Starting poll loop for new commands.
info: Setting initial orientation to PORTRAIT
info: Pushing command to appium work queue: "au.setScreenOrientation('PORTRAIT')"
debug: Sending command to instruments: au.setScreenOrientation('PORTRAIT')
info: [INSTSERVER] Socket data received (15 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Sending command to instruments: au.setScreenOrientation('PORTRAIT')
info: [INSTSERVER] Socket data received (56 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":"PORTRAIT"}
info: Device launched! Ready for commands (will time out in 60secs)
info: Appium session started with sessionId bcc46555-24e6-46b0-b725-d1d4b462af08
POST /wd/hub/session 303 46032ms - 9b
debug: Appium request initiated at /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08
debug: Request received with params: {}
info: Responding to client with success: {"status":0,"value":{"version":"6.0","webStorageEnabled":false,"locationContextEnabled":false,"browserName":"","platform":"Mac","javascriptEnabled":true,"databaseEnabled":false,"takesScreenshot":true,"device":"iPhone Simulator","app":"io.appium.TestApp"},"sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08"}
GET /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08 200 2ms - 382b
debug: Appium request initiated at /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/elements
debug: Request received with params: {"using":"tag name","sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08","value":"textField"}
info: Pushing command to appium work queue: "au.getElementsByType('textField')"
debug: Sending command to instruments: au.getElementsByType('textField')
info: [INSTSERVER] Sending command to instruments: au.getElementsByType('textField')
info: [INSTSERVER] Socket data received (79 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":[{"ELEMENT":"0"},{"ELEMENT":"1"}]}
info: Responding to client with success: {"status":0,"value":[{"ELEMENT":"0"},{"ELEMENT":"1"}],"sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08"}
POST /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/elements 200 1193ms - 157b
debug: Appium request initiated at /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/element/0/value
debug: Request received with params: {"sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08","id":"0","value":["1"]}
info: Pushing command to appium work queue: "au.getElement('0').setValueByType('1')"
debug: Sending command to instruments: au.getElement('0').setValueByType('1')
info: [INSTSERVER] Sending command to instruments: au.getElement('0').setValueByType('1')
info: [INSTSERVER] Socket data received (48 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":""}
info: Responding to client with success: {"status":0,"value":"","sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08"}
POST /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/element/0/value 200 2348ms - 87b
debug: Appium request initiated at /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/element/1/value
debug: Request received with params: {"sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08","id":"1","value":["5"]}
info: Pushing command to appium work queue: "au.getElement('1').setValueByType('5')"
debug: Sending command to instruments: au.getElement('1').setValueByType('5')
info: [INSTSERVER] Sending command to instruments: au.getElement('1').setValueByType('5')
info: [INSTSERVER] Socket data received (48 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":""}
info: Responding to client with success: {"status":0,"value":"","sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08"}
POST /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/element/1/value 200 1820ms - 87b
debug: Appium request initiated at /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/elements
debug: Request received with params: {"using":"tag name","sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08","value":"button"}
info: Pushing command to appium work queue: "au.getElementsByType('button')"
debug: Sending command to instruments: au.getElementsByType('button')
info: [INSTSERVER] Sending command to instruments: au.getElementsByType('button')
info: [INSTSERVER] Socket data received (143 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":[{"ELEMENT":"2"},{"ELEMENT":"3"},{"ELEMENT":"4"},{"ELEMENT":"5"},{"ELEMENT":"6"},{"ELEMENT":"7"}]}
info: Responding to client with success: {"status":0,"value":[{"ELEMENT":"2"},{"ELEMENT":"3"},{"ELEMENT":"4"},{"ELEMENT":"5"},{"ELEMENT":"6"},{"ELEMENT":"7"}],"sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08"}
POST /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/elements 200 1326ms - 293b
debug: Appium request initiated at /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/element/2/click
debug: Request received with params: {"sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08","id":"2"}
info: Pushing command to appium work queue: "au.tapById('2')"
debug: Sending command to instruments: au.tapById('2')
info: [INSTSERVER] Sending command to instruments: au.tapById('2')
info: [INSTSERVER] Socket data received (50 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":null}
info: Responding to client with success: {"status":0,"value":null,"sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08"}
POST /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/element/2/click 200 1174ms - 89b
debug: Appium request initiated at /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/elements
debug: Request received with params: {"using":"tag name","sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08","value":"staticText"}
info: Pushing command to appium work queue: "au.getElementsByType('staticText')"
debug: Sending command to instruments: au.getElementsByType('staticText')
info: [INSTSERVER] Sending command to instruments: au.getElementsByType('staticText')
info: [INSTSERVER] Socket data received (96 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":[{"ELEMENT":"8"},{"ELEMENT":"9"},{"ELEMENT":"10"}]}
info: Responding to client with success: {"status":0,"value":[{"ELEMENT":"8"},{"ELEMENT":"9"},{"ELEMENT":"10"}],"sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08"}
POST /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/elements 200 1347ms - 192b
debug: Appium request initiated at /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/element/8/text
debug: Request received with params: {"sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08","id":"8"}
info: Pushing command to appium work queue: "au.getElement('8').text()"
debug: Sending command to instruments: au.getElement('8').text()
info: [INSTSERVER] Sending command to instruments: au.getElement('8').text()
info: [INSTSERVER] Socket data received (49 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":"6"}
info: Responding to client with success: {"status":0,"value":"6","sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08"}
GET /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08/element/8/text 200 939ms - 88b
debug: Appium request initiated at /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08
debug: Request received with params: {"sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08"}
info: Shutting down appium session...
info: Stopping ios
info: [INST] 2013-12-06 10:50:50 +0000 Debug: target.setDeviceOrientation("1")
2013-12-06 10:50:53 +0000 Debug: target.frontMostApp().elements()[0].elements()[0].tap()
2013-12-06 10:50:54 +0000 Debug: target.frontMostApp().keyboard().typeString("1")
2013-12-06 10:50:55 +0000 Debug: target.frontMostApp().elements()[0].elements()[1].tap()
2013-12-06 10:50:56 +0000 Debug: target.frontMostApp().keyboard().typeString("5")
2013-12-06 10:50:58 +0000 Debug: target.frontMostApp().elements()[0].elements()[2].tap()
2013-12-06 10:51:00 +0000 Stopped: Script was stopped by the user
Instruments Trace Complete (Duration : 52.047413s; Output : /Users/Apple/instrumentscli0.trace)
info: [INSTSERVER] Instruments exited with code 0
info: Stopping iOS log capture
info: [INSTSERVER] Socket closed forcibly due to exit
info: [INSTSERVER] Instruments socket server closed
info: Deleted tracedir we heard about from instruments (/Users/Apple/instrumentscli0.trace)
info: Cleaning up appium session
info: Responding to client with success: {"status":0,"value":null,"sessionId":"bcc46555-24e6-46b0-b725-d1d4b462af08"}
DELETE /wd/hub/session/bcc46555-24e6-46b0-b725-d1d4b462af08 200 583ms - 89b
➜ python git:(master) ✗ python simple_real_device.py
.
----------------------------------------------------------------------
Ran 1 test in 56.793s
OK
➜ python git:(master) ✗
@luyi0824 首先你启动 appium 的时候
比如
appium -U 45f082689dbaebb0ffa3620b3ae22ad9faff9a30 --app io.appium
然后再去运行脚本。比如源码的案例下面的 examples/python/simple_real_device.py
理论上是这样,不过我遇到了一些问题。 没有成功的运行起来。
@meimeiyuyun 他说你 app 的地址不对╮(╯_╰)╭。 加个头像吧~
@mingway_hu @luyi0824 不好意思,这个问题没人解答过。估计论坛里没人试验过。
这个问题和传统的 web 自动化测试是一样的。 UI 的改变对自动化测试的代码影响有多大。
最基础的自动化,就是把所有的控件都 hard coding 在代码里。
稍微好一点,可以把控件抽离出来,放到资源文件中去。
最好的就是封装。在 web 中,有 page object。 我想在 app 里面应该也有 view object 或者类似的封装。
把控件之间的逻辑和控件本身解耦,是关键。
#5 楼 @seveniruby npm install -g appium@0.12 注意 node js 最好用 homebrew 安装,否则你要配置下权限。
中午的时候我已经报了 issue。 https://github.com/appium/appium/issues/1577。 @roicel 加个头像吧~
为 npm 默认选择 http 方式,不选用 https
npm config set registry http://registry.npmjs.org
https 你访问不了
@Test(enabled = false)
public void testScreenshot() {
//make screenshot and get is as base64
WebDriver augmentedDriver = new Augmenter().augment(driver);
String screenshot = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.BASE64);
assertNotNull(screenshot);
//make screenshot and save it to the local filesystem
File file = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
assertNotNull(file);
}
试试看。
本地调试方法:
➜ appium.io git:(master) jekyll serve
Configuration file: none
Source: /Users/Apple/code/appium.io
Destination: /Users/Apple/code/appium.io/_site
Generating... done.
Server address: http://0.0.0.0:4000
Server running... press ctrl-c to stop.
同学们,加个头像吧
#3 楼 @spikeshen 哦 这个问题 我一开始也发现了。 特别是在国内的各种机器上,默认输入法不同,会造成各式各样的问题。
有需要输入中文的代码片段么? 看看?
#4 楼 @xrj277427509 的确 appium 还在发展中,很多案列都缺少。
http://blog.appium.io/selenium-obj-c/ 看下这个。 其实就是 webdriver 不同的实现而已。你可以找一个 OC 实现的 webdriver bingding,然后进行 sample 代码的改造。 如果有所收获,欢迎向我们或者官方代码库 提出 merge request
#1 楼 @seveniruby 邀请他加入论坛吧
先看下文档吧?然后精华帖里面有很多 windows 下如何使用 appium 的帖子。
Appium 支持一个 Webdriver 元素定位方法的子集
find by "tag name" (i.e., 通过 UI 的控件类型)
find by "name" (i.e., 通过元素的文本, 标签, 或者开发同学添加的 id 标示, 比如 accessibilityIdentifier)
find by "xpath" (i.e., 具有一定约束的路径抽象标示, 基于 XPath 方式)
建议通读,https://github.com/appium/appium/blob/master/docs/cn/finding-elements.cn.md。不过其实就是普通的 xpath。和 网页的差不多。
和https://github.com/appium/appium/tree/master/docs/cn这里的文档。