最近在研究Appium做UI自动化测试,下面是在这过程中遇见的各种问题,本问题合集使用sample-code进行测试
Appium测试TestAPP时报错解决方法
1. Xcode-Version 7.3.1 (7D1014)使用Appium提供的测试用例TestAPP时编译时报错:
/Users/HeminWon/Desktop/sample-code-master/sample-code/apps/TestApp/Test App 2/GestureTestViewController.xib: Internal error. Please file a bug at bugreport.apple.com and attach "/var/folders/0m/mm1tf5394t78gnkpxt9jnslc0000gn/T/IB-agent-diagnostics_2016-05-19_23-31-34_869000".
解决方法:
BuildSetting -> Build Settings -> OSACompile-Build Options -> Save as Execute-Only - > No→Yes
参考来源:LaunchScreen-iPad.xib internal error.
2. 全局代理模式下运行appium时,python运行脚本不成功
原因:因全局代理模式下下无法访问到127.0.0.1,所以请关闭全局代理.
3. 使用测试用例TestAPP,终端运行脚本ios_simple.py时,Appium报出以下错误
error: Could not reset simulator. Leaving as is. Error: Command 'xcrun simctl erase 3E6EEACD-7542-447F-B768-2C8FE8B0975E' exited with code 159
解决方法:在Appium的GUI客户端中打开使用本地仿真库
Appium -> iOS Settings - > Advanced -> Use Native Instruments Library 这个选项打上勾
参考来源:Appium not running iOS Simulator - Mac OSX El Capitan
4. 使用测试用例UICatalog,运行脚本ios_complex.py时,Appium无法自动化测试并报出以下错误
Traceback (most recent call last):
File "ITest0623.py", line 9, in <module>
from appium import webdriver
ImportError: No module named appium
解决方法:安装的python-client使用Homebrew未完全安装正确,使用Git下载python-client安装
git clone https://github.com/appium/python-client
# cd到下载的python-client
cd python-client
#以下命令可能需要使用sudo命令
python setup.py install
参考来源:http://www.jianshu.com/p/a359a43fc48f
5. 使用测试用例UICatalog,运行脚本ios_complex.py时,Appium日志显示以下错误
error: Failed to start an Appium session, err was: Error: Bad app: /Users/hulianghai/Desktop/sample-code/sample-code/apps/UICatalog/build/release-iphonesimulator/UICatalog.app. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat '/Users/hulianghai/Desktop/sample-code/sample-code/apps/UICatalog/build/release-iphonesimulator/UICatalog.app'
错误原因:未注意脚本语言里面“app = os.path.abspath”设置的路径需要与客户端Appium测试的app路径保持一致,参考其他脚本或者官方文档重新设置路径