无法使用Appium打开和关闭位置服务
在测试之前,我需要在Android中启用和禁用位置服务。我尝试过以下的解决方案,但没有任何效果 情景:1 亚洲开发银行命令 adb外壳设置放置安全位置\u提供商\u允许+网络,gps adb外壳设置放置安全位置\u允许提供程序\u-网络、gps 这些命令有时工作,但不是所有的时间,所以我的测试失败了很多次禁用 情景:2 toggleLocationService()方法无法使用Appium打开和关闭位置服务,appium,Appium,在测试之前,我需要在Android中启用和禁用位置服务。我尝试过以下的解决方案,但没有任何效果 情景:1 亚洲开发银行命令 adb外壳设置放置安全位置\u提供商\u允许+网络,gps adb外壳设置放置安全位置\u允许提供程序\u-网络、gps 这些命令有时工作,但不是所有的时间,所以我的测试失败了很多次禁用 情景:2 toggleLocationService()方法 公共静态无效启用和禁用位置(AppiumDriver驱动程序){ ((AndroidDriver)driver.openNot
公共静态无效启用和禁用位置(AppiumDriver驱动程序){
((AndroidDriver)driver.openNotifications();
((AndroidDriver)driver).toggleLocationServices();
}
是否有其他解决方案可以使用Appium在Android中启用和禁用位置服务。在启用和禁用之前,我还想知道位置的状态
我使用的是Java客户端5.0.4
使用Android牛轧糖进行测试。以启用:
adb shell settings put secure location_providers_allowed +gps
adb shell settings put secure location_providers_allowed +network
要禁用:
adb shell settings put secure location_providers_allowed -gps
adb shell settings put secure location_providers_allowed -network
adb shell settings put secure location_providers_allowed -gps
adb shell settings put secure location_providers_allowed -network