how to automate the airplane mode in appium automation

☆樱花仙子☆ 提交于 2020-05-31 07:21:29

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!