问题
In my test, I've declare an AppiumDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL(completeURL), capabilities);
but I didnt't get any defined method to perform setConnection operation with this driver declaration. Please let me know how can I set my driver.setConnection to Airplane mode.
回答1:
You can use Toggle Airplane Mode.
// Java
driver.toggleAirplaneMode();
// JavaScript
driver.toggleAirplaneMode();
// Ruby
@driver.toggle_flight_mode
回答2:
I have tried this in Appium version 1.15.1 You can easily change the airplane mode by performing click action on it. First open the notification panel.
((AndroidDriver<?>)driver).openNotifications();
use 1 sec delay
Thread.sleep(1000);
use the inspector to spy the airplane mode property, I have used the xpath for this.
driver.findElement(By.xpath("Xpath for airplane mode")).click();
and, close the notification panel after this.
((AndroidDriver<?>)driver).pressKey(new KeyEvent(AndroidKey.BACK));
来源:https://stackoverflow.com/questions/50838598/how-to-automate-the-airplane-mode-in-appium-automation