【问题标题】:Appium - runAppInBackground throws WebDriverExceptionAppium - runAppInBackground 抛出 WebDriverException
【发布时间】:2018-09-30 04:50:26
【问题描述】:

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

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

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

appiumDriver 变量是静态的(不确定这是否会有所不同...)。

感谢您的帮助!

【问题讨论】:

    标签: android selenium selenium-webdriver appium


    【解决方案1】:

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

    通过将 Appium 从 1.7.2 更新到 1.8.1,问题得到解决。

    【讨论】:

      【解决方案2】:

      很清楚堆栈跟踪中出了什么问题: 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 秒和不同的设备。

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

      【讨论】:

      • 感谢您的建议! 5 秒,不同的设备对我不起作用。目前我无法更改应用源代码,希望以后可以尝试。
      猜你喜欢
      • 2019-12-30
      • 2018-09-23
      • 1970-01-01
      • 2015-12-26
      • 1970-01-01
      • 1970-01-01
      • 2021-06-30
      • 2023-01-05
      • 2017-06-17
      相关资源
      最近更新 更多