@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这里的文档。
还有 10 篇~
就是 用 nodejs 写的测试用例。 你可以用别的语言来写。 比如你的测试用例使用 python 写的,那就是python your-appium-test.py
#2 楼 @whuiscool 没啥不同吧,本质是一样的。
#2 楼 @shery_zhang2012 了解,谢谢。appium 封装的东西还是不太多。
#2 楼 @guo initial conditions test 是 Android 测试里面用的,就是 check 一些最基本的应用对象,来确保之后的测试是否有意义。
其实可以去 appium 的 Google group 问下,我估计没有什么好的解决方法。 @seveniruby
I feel like we see this message for other reasons too, like the app isn't compiled correctly. Also, restarting the app doesn't necessarily put it into a state where the test can continue. If the app crashes or dies, I think we should end the session and 500 the currently request.
用 initial conditions test?
报错的时候,先捕获异常,然后看下被测程序是否已经异常退出了,如果退出了,就自定义自己的异常,否则就抛出捕获的异常?