I'm using method getConnection to check what network interface device is on, but when I am on cellular data interface and switch to wifi, it takes some time to change it, but getConnection method returns WIFI even though device is still on data as switching interfaces is still in progress.
Is there any other way to check or to wait, until the interface switch is finished?
I'll talk about this also in my talk in AppiumConf. You can use:
adb shell dumpsys wifi
and look for curState information. When it reaches CompletedState you are connected to Access Point.
You can use:
driver.executeScript("mobile: shell", commandAndArgs);
to run command on remote device.
Cool thanks, that's good solution.. This is my method I use to check WiFi state:
private boolean isWifiStateConnected(){
Map<String, Object> args = new HashMap<>();
args.put("command", "dumpsys");
args.put("args", "wifi");
String response = (String) getAndroidProxiedDriver().executeScript("mobile: shell", args);
return response.contains("curState=ConnectedState");
}
and I'm waiting for connected state in empty while(!isWifiStateConnected());
(there should be some test run timeout or iteration count, so your tests won't stuck on this)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.