Is there any way to get the status of button in appium in Android/iOS

I have to automate one scenario wherein i need to check if the Location is ON/OFF. So in Android i am able to Access the Notification panel using .OpenNotifications(); and then i check if Location service is ON/OFF by inspecting the Location button.

Now in this case i need to know if the Location button state if On/Off.

Any solutions?

we did similar for iOS but in Simulator. the idea was:

  • press home button
  • locate settings icon and tap on it and so on

we also simulated location with osascript in Simulator with menu Debug -> Location -> None/Custom

Ok, Is there any way for Android to detect the Location button state if it is ON/OFF? I can locate the Location button element using //*[@text=‘Location’] since we know in all devices this element is same in terms of text but getting the button state was challenging.

you can use

((AndroidDriver) driver).toggleLocationServices();

and check value

((AndroidDriver) driver).toggleLocationServices();
The return type of above method is void. So it wont return me anything inorder to check the value.

But yes this will launch the Location service Settings page but does nothing.

you need to check it location setting and enable/disable it yourself

Do you mean to check location on App side itself? And Appuim driver cannot do this?

i mean you in test code can get this value and get knowledge - does location enabled on device or not.