I need to enable and disable location service in Android before my test. I have tried the following solutions but nothing worked at all.
Scenario : 1 ADB commands
adb shell settings put secure location_providers_allowed +network,gps adb shell settings put secure location_providers_allowed -network,gps
These commands working at times but not all the times so my test fails lot of times for disabling.
Scenario : 2 toggleLocationService() Method
public static void enableAndDisableLocation(AppiumDriver driver) {
((AndroidDriver) driver).openNotifications();
((AndroidDriver) driver).toggleLocationServices();
}
Are there any other solution to enable and disable Location service in Android using Appium. Also I want to know the status of the Location before enabling and disabling.
I am using Java client 5.0.4 Testing in Android Nougat.