Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access iOS Control Center using appium

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

    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

Instead of opening control centre the app simply draws on the screen upwards from the bottom (using coordinates input). Anyone know how to open Control Center using appium and swipe (or any other way)?

Thanks, Charlie

like image 540
Charlie Seligman Avatar asked Jun 18 '15 11:06

Charlie Seligman


2 Answers

We can do this. I tried in Appium 1.4.13 and I am able to change settings.

I used below code to change the settings in my 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();
like image 193
Shiva krishna Chippa Avatar answered Oct 06 '22 16:10

Shiva krishna Chippa


Appium 1.6.5, You can use swipe method, bellow my Python code:

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() 
like image 27
Lukas Lewandowski Avatar answered Oct 06 '22 15:10

Lukas Lewandowski