Is there a way to turn Off/On Android Device Location using Xamrine UItest?

Gnanaprakasam, Kalaimamani 21 Reputation points
2020-11-20T01:46:18.94+00:00

I have a test Case in my App where Location should be Off. Is it possible using Xamarin.UItest

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,357 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 76,001 Reputation points Microsoft Vendor
    2020-11-20T07:20:08.96+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Does your emulator support adb root? If you emulator support root, you can use adb command to disable the device location

       adb shell settings put secure location_providers_allowed -gps  
    

    Use following command to enable the location.

       adb shell settings put secure location_providers_allowed +gps  
    

    how to execute the adb command in uitest, you can refer to this thread :https://stackoverflow.com/questions/50364672/enable-disable-wifi-using-xamarin-uitest

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.