How can i check current GPS status in my test, I want to know if it’s in use.
I don’t think you can do it with Appium. Try a system call to adb, like:
adb shell dumpsys location
Thank for the answer
Yes, this works.
when the application use gps i have:
Active Records by Provider:
gps:
UpdateRecord[gps application(10070) Request[ACCURACY_FINE gps requested=+30s0ms fastest=+30s0ms]]
if the gps is not in use:
Active Records by Provider:
gps:
is empty
adb shell dumpsys location
With this i have a log. I need to extract only this information from the log, How can I proceed?
I don’t know what language you are using, but assign the output of the adb system call to a variable and then parse the results (possibly with regex) to find the status.
I’m using Java, can you provide an example?
Here is a pretty good tutorial on Java System Calls:
https://blog.art-of-coding.eu/executing-operating-system-commands-from-java/
And here is one on parsing a String in Java:
https://docs.oracle.com/javase/tutorial/datetime/iso/format.html
The example is parsing date/time, but that can be adapted to anything.