Подтвердить что ты не робот

Доступ к Центру управления iOS с помощью appium

Я пытаюсь открыть Центр управления с помощью 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

Вместо открытия центра управления приложение просто рисует вверх экран снизу (используя ввод координат). Кто-нибудь знает, как открыть Control Center, используя appium и проведите (или любым другим способом)?

Спасибо, Чарли

4b9b3361

Ответ 1

Хорошо, поэтому, после большого количества расследований, мне кажется, что это невозможно. Если вам действительно нужна эта функциональность, я думаю, что такой инструмент, как баклажан, может быть уместным.

Ответ 2

Мы можем это сделать. Я попытался в 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();

Ответ 3

Appium 1.6.5, вы можете использовать метод swipe, ниже мой код 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() 

Ответ 4

Я могу переключить Wifi OFF или включить режим полета с помощью Appium 1.6.4-beta для iOS

Проведите по экрану снизу экрана Нажмите ссылку "Продолжить" Нажмите кнопку Wi-Fi или 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();
}

Ответ 5

Этот код поможет открыть Центр управления, пока вы находитесь в своем приложении, вы можете выполнять все операции, доступные в Центре управления.

new TouchAction(DriverConfig.getInstance().getDriver()).press(point(250, 735)).waitAction(waitOptions(Duration.ofSeconds(3))).moveTo(point(250, -460)).release()
                        .perform();