在真机上跑APPIUM自动化的那些坑
转自https://blog.csdn.net/mentgmery1/article/details/41645427
第一个坑,怎么启动APPIUM,以保证它与APPIUM SERVER通信,
appium -U UDID--app Bundle ID
第二个坑,
selenium.common.exceptions.WebDriverException: Message: u'A new session could not be created. (Original error: Instruments crashed on startup)'
我遇到这个问题两次,简单描述如下:
第一次,是因为developer选项里的 Enable UI Automation木有开启,开启后就OK了。这里解释一下,在真机上跑APPIUM的前提是,手机应该注册成开发者手机,这样就可以在Settings的页面看到 Developer(开发者)这个选项了。
第二次,则是因为,换了手机之后,因为手机不支持我现在使用的APP的签名,导致了Instruments crashed on startup的错误,只要把用这个手机的签名重新编译一个APP,就可以了。
第三坑
switch_to.context测试,老是报错,没有context这个attribute,找乐半天才发现,
from appium import webdriver
from selenium import webdriver
第二条声明把第一条给覆盖了,switch_to是appium里的方法。
第四个坑
打开浏览器操作,http://appium.io/slate/en/v1.2.1/?python#setup76
【在真机上跑APPIUM自动化的那些坑】第五个坑
Appium v1.3.1 启动IOS测试后报了如下异常,记得之前可以跑的,点里那个诊断的按钮也显示环境正常,请大家帮我看看是哪里出问题了么? 这个文件/Applications/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller我看也有的啊。
2014-11-04 01:26:38:474 - info: [debug] Not pre-launching simulator
2014-11-04 01:26:38:474 - info: [debug] Creating iDevice object with udid 843bb46631ac5c1408af67ae25a48d3b2e2c4888
2014-11-04 01:26:38:475 - info: [debug] Couldn't find ideviceinstaller, trying built-in at /Applications/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller
2014-11-04 01:26:38:475 - info: [debug] Checking app install status using: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap isInstalled --id 843bb46631ac5c1408af67ae25a48d3b2e2c4888 --bundle com.terrytest.test
2014-11-04 01:26:40:637 - info: [debug] App is not installed. Will try to install the app.
2014-11-04 01:26:40:637 - info: [debug] Installing ipa found at /Users/sunqingwei/Evan/terrytest/Mobile/test.ipa
2014-11-04 01:26:40:637 - info: [debug] Creating iDevice object with udid 843bb46631ac5c1408af67ae25a48d3b2e2c4888
2014-11-04 01:26:40:638 - info: [debug] Couldn't find ideviceinstaller, trying built-in at /Applications/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller
2014-11-04 01:26:40:839 - info: [debug] Cleaning up appium session
2014-11-04 01:26:40:840 - info: [debug] Error: Command failed: dyld: Library not loaded: @executable_path/../lib/libimobiledevice.3.dylib
Referenced from: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller
Reason: image not found
at ChildProcess.exithandler (child_process.js:648:15)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
2014-11-04 01:26:40:839 - error: Failed to start an Appium session, err was: Error: Command failed: dyld: Library not loaded: @executable_path/../lib/libimobiledevice.3.dylib
Referenced from: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller
Reason: image not found
2014-11-04 01:26:40:840 - info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Command failed: dyld: Library not loaded: @executable_path/../lib/libimobiledevice.3.dylib\nReferenced from: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller\nReason: image not found\n)","killed":false,"code":null,"signal":"SIGTRAP","origValue":"Command failed: dyld: Library not loaded: @executable_path/../lib/libimobiledevice.3.dylib\nReferenced from: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller\nReason: image not found\n"},"sessionId":null}
2014-11-04 01:26:40:841 - info: <-- POST /wd/hub/session 500 4929.943 ms - 668
这个就是你的ideviceinstaller没装好,brew install ideviceinstaller 执行
第五个坑
"message":"A new session could not be created. (Original error: Instruments crashed on startup)","origValue":"Instruments crashed on startup"},"sessionId":null}
一般出现这个问题,都是你的APP的签名跟设备的不一样导致,保持一致就可以了
第六个坑
第七个坑
安装特定版本的APPIUM
npm install -g appium@0.12.3
第八个坑
在真机上生成的APP文件和在模拟器(simulator)上生成的是不一样的,用inspector的时候,只能使用模拟器生成的APP文件
第九个坑
UIAPickerWheel, 比如 picker里面有4个选项, latest day, last 7 days, last 30 days, all, 这个时候只需要UIAPickerWheel.send_keys(latest day),就可以设置picker里的值
第十个坑
通过INSPECTOR,发现有多个元素的名字都是一样的,我们可以通过find_elements_by_name方法(记住是elements)遍历所有相同名字的元素,然后根据INDEX取其中我们想要的,例如,
def getPicker(self):
elements = find_elements_by_name("picker normal")
return elements[1]
推荐阅读
- 《真与假的困惑》???|《真与假的困惑》??? ——致良知是一种伟大的力量
- 你到家了吗
- 闲杂“细雨”
- 杜月笙的口才
- 赢在人生六项精进二阶Day3复盘
- 祖母走了
- 樱花雨
- 眼观耳听美食的日子
- 年味真的是越来越淡了么
- “成长”读书社群招募