一、appium做app自动化遇到的问题汇总
1、Android版本填写错误
‘platformVersion’:’11’
我手机上的版本明明是11,但是填了之后,居然不对,报错:
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Unable to find an active device or emulator with OS 8. The following are available: FEC0220515006984 (10)
嘿嘿,有提示,刚开始以为是FEC0220515006984,不对,填括号内的10就对了!还有就是,原来不是看版本号,而是要看“Android版本”
2、appPackage或者appActivity包填写错误
报错信息:
‘appPackage’:‘tv.danmaku.bili’
填错的话,会报错:
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Cannot start the ‘tv.danmaku.ili’ application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Activity name ‘.MainActivityV2’ used to start the app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity

‘appActivity’: ‘.MainActivityV2’
填错的话,会报错:
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Cannot start the ‘tv.danmaku.bili’ application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Activity name ‘.AMainActivityV2’ used to start the app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity
怎么获取真实的appPackage或者appActivity:
1、通过.apk安装包获取
aapt dump badging D:\app_dir\xxxxxx.apk
2、获取模拟器正在运行的APP的Package和Activity

adb shell dumpsys activity | find “mFocusedActivity”
3、(最喜欢用这个)获取真机正在运行的APP的Package和Activity,在手机上把所有应用关闭,只打开自己想看的app:
adb shell dumpsys activity | find “mResumedActivity”
在这里插入图片描述

别忘了小数点!!!
4、获取当前页面的Package和Activity
adb shell dumpsys window | findstr mCurrentFocus
5、列出模拟器或真机中所有软件的Package
adb shell pm list packages
6、获取带端口号的Activity
adb shell dumpsys activity top | findstr ACTIVITY
二、第一次运行:
第一次运行会比较慢,因为会在手机上面自动安装Appium Server 和android.apk这两个软件

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐