我正在使用appium和python selenium webdriver执行脚本。我有一个场景,我需要在真正的android设备上打开飞行模式。我在脚本中使用了driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE)。但是它显示了一些"Operation is Unsupported on Android“msg。
有没有替代的方法来完成上面的操作?
详细信息:
驱动程序: Webdriver
Appium: 1.4.16。
设备操作系统: 4.4.4
用Python编写脚本。
发布于 2017-10-12 08:33:30
我们通过自动化启用飞机模式的步骤来做到这一点,即编写代码打开菜单并单击飞机模式按钮。
下面是相同的代码片段。
public void enableAirplaneMode(AndroidDriver driver)
{
driver.swipe(350, 10, 350, 700, 1000);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.swipe(350, 10, 350, 700, 1000);
WebDriverWait wait = new WebDriverWait(driver, 50);
wait.until(ExpectedConditions.visibilityOfElementLocated(MobileBy.AccessibilityId("Airplane mode")));
String AirplaneMode=driver.findElement(MobileBy.AccessibilityId("Airplane mode")).getText();
if (AirplaneMode.equals("Off"))
{
driver.findElement(MobileBy.AccessibilityId("Airplane mode")).click();
}
driver.swipe(350, 800, 350, 10, 1000);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.swipe(350, 800, 350, 10, 1000);
}希望这能帮上忙。
https://stackoverflow.com/questions/43116010
复制相似问题