使用appium访问iOS控制中心

我试图用appium和下面的代码打开控制中心:

int halfWidth = driver.manage().window().getSize().width / 2; int screenHeight = driver.manage().window().getSize().height; driver.swipe(halfWidth, screenHeight-5, halfWidth, screenHeight-300, 500); // driver is instance of IOSDriver 

应用程序只需从底部向上绘制屏幕(使用坐标input),而不是打开控制中心。 任何人都知道如何使用appium和滑动(或任何其他方式)打开控制中心?

谢谢,查理

我们做得到。 我试图在Appium 1.4.13中,我可以改变设置。

我使用下面的代码来更改我的iPadAir2中的设置。

 int height = driver.findElementByClassName("UIAWindow").getSize().getHeight(); int width = driver.findElementByClassName("UIAWindow").getSize().getWidth(); driver.swipe(width-100, height, width-100, height-200, 500); driver.findElementByAccessibilityId("Wi-Fi").click(); 

我可以使用iOS的Appium 1.6.4-beta切换WiFi OFF或打开飞行模式

从屏幕底部向上滑动单击继续链接单击Wifi或Airplanebutton从屏幕中间向下滑动

但是这似乎没有在模拟器中做任何事情。 我必须实际上closures我的电脑互联网连接,以禁用模拟器上的互联网。

 @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(); } 

Appium 1.6.5,您可以使用滑动方法,在我的Python代码中:

 window_size = self.driver.get_window_size() # this returns dictionary el = self.driver.find_element(*self.configuration.CommonScreen.WEB_VIEW) action = TouchAction(self.driver) start_x = window_size["width"] * 0.5 start_y = window_size["height"] end_x = window_size["width"] * 0.5 end_y = window_size["height"] * 0.5 action.press(el, start_x, start_y).wait(100).move_to(el, end_x, end_y).release().perform() 

好吧,经过相当多的调查,我觉得这是不可能的。 如果你真的需要这个function,那么我认为像茄子这样的工具可能是合适的。