Appium - runAppInBackground抛出WebDriverException

时间:2018-04-16 13:04:13

标签: android selenium selenium-webdriver appium

我正在使用Appium来自动化Android应用的测试。最近我在尝试测试应用程序的行为时遇到了错误,当它被推送到后台并再次重新启动时。我很幸运,我找到了方法appiumDriver.runAppInBackground(Duration duration)

...但是当我执行appiumDriver.runAppInBackground(Duration.ofSeconds(1));时,我收到了一个例外。

我在Android模拟器(PIXEL_API_25)上运行测试,我使用Appium 1.7.2和java_client 5.0.4,但将来它们也应该在iOS上运行。

appiumDriver变量是静态的(不确定这是否会产生影响......)。

感谢您的帮助!

2 个答案:

答案 0 :(得分:2)

与此同时,我找到了一个适合我的解决方案。

将Appium从1.7.2更新到1.8.1时,问题就解决了。

答案 1 :(得分:1)

很清楚stacktrace出了什么问题: Original error: 'Command ''C:\\Users\\User\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe' -P 5037 -s emulator-5554 shell am start -W -n de.abc.myApp/.BookingOverviewActivity' exited with code 1'; Stderr: 'java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=de.abc.myApp/.BookingOverviewActivity } from null (pid=7759, uid=2000) not exported from uid 10224 由于权限限制,Appium无法从后台启动您的应用。尝试使用5秒钟和不同的设备。

如果仍然重现:要修复它,您需要在android:exported="true"活动的清单文件中使用BookingOverviewActivity更新应用程序源代码。