Access iOS Control Center using appium

后端 未结 7 1849
一整个雨季
一整个雨季 2021-01-01 23:48

I am trying to open the Control Center using appium and the following code:

    int halfWidth = driver.manage().window().getSize().width / 2;
    int screenH         


        
7条回答
  •  感动是毒
    2021-01-01 23:53

    I am able to toggle the Wifi OFF or turn Airplane mode ON using Appium 1.6.4-beta for iOS

    Swipe up from the bottom of the screen Click continue link Click the Wifi or Airplane button Swipe down from middle of screen

    But this doesn't appear to be doing anything in the simulator. I have to actually turn off my computers internet connection to disable the internet on the simulator.

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

提交回复
热议问题