我可以使用适用于 iOS 的 Appium 1.6.4-beta 关闭 Wifi 或打开飞行模式
从屏幕底部向上滑动 点击继续链接 点击 Wifi 或 Airplane 按钮 从屏幕中间向下滑动
但这似乎在模拟器中没有做任何事情。我实际上必须关闭我的计算机互联网连接才能禁用模拟器上的互联网。
@iOSFindBy(xpath = "//XCUIElementTypeSwitch[@name='Wi-Fi']")
private MobileElement WIFI_MODE_BUTTON;
public void disableWifi() {
openToolBarMenu();
//if wifi is on/true then turn it off
if (WIFI_MODE_BUTTON.getAttribute("value") == "true" ) {
Autoscope.tap(WIFI_MODE_BUTTON);
}
closeToolBarMenu();
}
@iOSFindBy(xpath = "//XCUIElementTypeButton[@name='Continue']")
private MobileElement CONTINUE_BUTTON; //continue button on control center
public void openToolBarMenu() {
Autoscope.scrollFromBottomOfScreen();
if (Autoscope.isElementDisplayed(CONTINUE_BUTTON)) {
Autoscope.tap(CONTINUE_BUTTON);
}
}
static public void scrollFromBottomOfScreen() {
TouchAction touchAction = new TouchAction(autoscopeDriver);
int xStartPoint = Math.round(pixelWidth() / 2);
int yStartPoint = pixelHeight();
int yEndPoint = 0 - yStartPoint;
touchAction.press(xStartPoint, yStartPoint).moveTo(0, yEndPoint).release().perform();
}