'How to verify icon's presence in statusBar of Android with Selenium?
I need to write code (Java, Selenium) that verifies icon's presence in Android status bar. For instance, after enabling airplane mode, a plane icon appears. But I can't figure out how to do this, what selectors should be used? Appium desktop doesn't seem to work with the status bar and 'adb shell dumpsys statusbar' also gives no useful info. I have written verifications of the elements in the notification bar, quick options, etc, but I'm stuck at finding about status bar icons. Please help.
Solution 1:[1]
So, I've found a way to verify it via dumpsys of systemUIservice. The code looks like this:
public static boolean validateAirplaneModeBySystemUIService(DeviceAng deviceAng) throws Exception {
String systemUIService = "activity service SystemUIService";
return deviceAng.getADB().shell().dumpsys().service(systemUIService, "mAirplaneMode=true").GetBoolean()
&& deviceAng.getADB().shell().dumpsys().service(systemUIService,
"icon=StatusBarMobileView(slot=mobile state=MobileIconState").GetString().contains("visible=false")
&& deviceAng.getADB().shell().dumpsys().service(systemUIService,
"icon=StatusBarIconView(slot=airplane icon=StatusBarIcon").GetString().contains("visible user=0");
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Maxim Simonov |