- Newest
- Most votes
- Most comments
Based on the information provided, there isn't a direct method in AWS Device Farm to prevent the Android Location Accuracy popup from displaying during your Appium tests.
The approaches you've tried so far:
- Using
autoGrantPermissions
in your capabilities - this handles basic permissions but not the Location Accuracy popup specifically - Using Appium's
setGeolocation
method - this works locally but isn't supported in Device Farm as shown by the error message - Setting location in the AWS Device Farm schedule-run command - this didn't prevent the popup
Since Device Farm has limited support for certain Appium commands (as evidenced by the error message listing only supported commands), you may need to handle this popup programmatically in your tests. While you mentioned wanting to avoid adding code to handle the popup, it might be the most reliable solution given the constraints.
You could try:
- Adding code to detect and dismiss the popup when it appears
- Using custom test environments in Device Farm with a test spec that might allow you to configure location settings before your tests run
- Exploring if any of the supported mobile commands like
changePermissions
orgetPermissions
could help with this specific scenario
Unfortunately, there doesn't appear to be a straightforward way to prevent this popup from appearing in Device Farm without handling it within your test code.
Sources
Speeding up Appium-based tests in Device Farm through desired capabilities - AWS Device Farm
I've tried a few more settings and found that the deprecated method driver.setGeoLocation() still works and stops the popup displaying. I've added this function to my setup that gets called before the user logs into our app and is prompted for the location permissions.
Ideally the driver.execute('mobile: setGeolocation') version above would work so if its possible to add support for this in future that would be great.
static async setLocation(latitude: number = 51.5074, longitude: number = -0.1278) {
await driver.setGeoLocation({ latitude, longitude });
}
Before this I also tried adding mockLocationApp to the wdio conf capabilities to see if it stopped the popup but it didn't.
capabilities: [{
// capabilities for local Appium web tests on an Android Emulator
platformName: 'Android',
'appium:automationName': 'UiAutomator2',
'appium:deviceName': 'Android',
'appium:autoGrantPermissions': true,
'appium:mockLocationApp': 'io.appium.settings'
}],
I also tried revoking the ACCESS_FINE_LOCATION permission for the app to see if that stopped the app Location Accuracy prompt but it didn't work either.
await driver.execute('mobile: changePermissions', {
appPackage: 'com.example.myapp',
permissions: [
'android.permission.ACCESS_FINE_LOCATION',
],
action: 'revoke'
});
Relevant content
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 4 years ago