在 stackoverflow 找到一个比较靠谱的答案:
the explanation is android 4.3 has the id component in uiautomatorviewer. Android versions less than API level 18 will not be able to interact with the resource-id of the element.
只有 API level 18 (4.3) 以上的 UIAutomator 才能使用 resource-id 。
给多一些信息啊,例如模拟器的 Android 是什么版本,真机是什么版本,没有 id 这一项具体是什么情况(发个有 id 的和没 id 的 UIAutomatorViewer 截图对比一下)?
UIAutomator 不需要 root 的。
#1 楼 @cissysnail 另外,根据你的 logcat ,问题应该出在你的 apk 上。第一个错误提示不是说找不到文件,是说这个动态库指向的链接出错。
从截图和你的描述上看,你使用的真机和模拟器最大的区别是你的模拟器配置使用 x86 处理器,真机一般使用 arm 处理器,你确定你的 apk 能在不作修改的情况下在 x86 上工作吗?如果不确定,你找个 x86 的真机试试就知道了。
PS:麻烦改一下标题,你这个是 Android 模拟器,不是虚拟机……
我查到这个相关 issue :
https://github.com/appium/appium/issues/4216
里面有一个人提到
@ShiranDadon was correct about the UDID being incorrect. On my Windows device, I retrieved the UDID from iTunes (not sure where else to get it from on Windows), and iTunes makes all characters in the UDID uppercase. If you use XCode on a Mac to get the UDID, the alphabetic characters are all lowercase (as least for my device).
By using the uppercase UDID, I am able to reproduce the issue. By using the correct UDID from XCode, the issue is NOT reproducible.
你试试把 UDID 改为全小写?
PS:下次贴代码或 log 麻烦用代码块。
这个签名不是在打包的时候设置的,是在应用里的 Provisioning Profile 选项里面设置的。
你用这个错误信息去 stackoverflow 搜一下就有详细答案了。
这句话不是告诉你了吗:
instruments Permission to debug com.xxxx.xxxxx was denied , The app must be signed with a devepoment identity (e.g. iOS Developer)
赞!收获还是不少的嘛。
建议后面麻烦排一下版,不同部分加一下小标题,代码用代码块,该加粗的加粗一下,该留空行的留一下空行。方便阅读。
请提供你的环境信息:
appium 版本
appium 类型(npm,app,exe,源码)
另外,试试brew install ideviceinstaller,不知道brew是什么麻烦自行百度。
#17 楼 @nancy2896 想法不错,你这个逻辑其实就是 waitForElement 的逻辑,问题在于 UIObject 取不到 toast。。。toast 不会出现在 dump 出来的 xml 中。
目前能获取 toast 的框架(Robotium,selendroid)都是通过 instrumentation 内的 getView() 方法获取(方法名我不是很确定是不是这个),不是 uiautomator。
#15 楼 @nancy2896 就是因为 uiautomator 没有这个 API,所以我们要另外想办法搞。。。
#11 楼 @springs412 你先确认一下从主机访问从机的入口(如http://172.17.6.173:4723/wd/hub,172.17.6.173是从机地址)看能否访问?
如果不行,检查一下网络(防火墙、是否在同一网络等)
appium server 在从机打开就好了。
logcat 命令有过滤器参数的:
http://www.miui.com/article-272-1.html
很不错的入门介绍。如果能把各个默认模板都有简单介绍就好了。
另外解答一下你的问题:
4.运行程序 building(这个我没有实现,不晓得哪里不对)
原文的意思:如果你想在 build 后在 Instruments 中运行被测应用,请长按 Run 按钮(像播放按钮的那个),然后在出现的菜单里选择 profile,或者直接在 Product 菜单里选择 profile。(实际上就是在 build 后自动打开 instruments 给你)
这个就是 WebDriver 的 RemoteDriver 的特性吧。Appium 本质上是一个 RemoteDriver(最早的时候它的 client 用的就是 RemoteDriver)。只要网络能联通,client 与 server 之间无论是否在同一台机器上都没问题的。
如果是用其他 webdriver(如 ChromeDriver),也可以用 SeleniumRC 来作为远程服务器,然后 client 连去服务器进而控制远程机器的 webdriver。
你的 URL 有很明显的问题,所以会出错。
这个 URL("http://127.0.0.1:4723/wd/hubappium")是 server 的 REST API 入口,至于入口为啥是这个、后面具体怎么使用请了解一下 WebDriver,RemoteDriver 的概念和规范。
额,其实我也在学习中。。。
我目前能想到的有:
单元测试:如果输入的不是号码会如何处理?传个不是号码/非法号码的值给 ACTION_CALL 会有什么后果,根据这个后果是否需要在传入前校验?(大多数拨号盘只有合法字符,而你使用输入框,所以需要自己做非法字符的处理)
UI 测试:UI 兼容性如何(2.x,4.x,主流手机系统,各个分辨率)?输入框或按钮在某些情况下会否被挡住(如低分辨率下)?
功能测试:没有获取到权限的话拨号功能会怎样(不少手机系统默认不给权限),是否有清晰的错误提示?输入非法字符是否能提示?点击按钮后是否能正确调用拨号应用?
推荐你看看剪烛 mm 的这个帖子,里面说得比较全面:
http://testerhome.com/topics/2272