Manoj R B
Manoj R B

Reputation: 11

How to swipe in IOS7 using appium?

I am new to this mobile automation.I have tried below methods to swipe in ios7 simulator but none of them worked for me.

1)

HashMap<String, Integer>() map = new HashMap<String, Integer>() {
            {
                put("touchCount", 1);
                put("startX",225);
                put("startY", 500);
                put("endX", 225);
                put("endY", 250);
                put("duration", 5);
            }
        };
        ((JavascriptExecutor) driver).executeScript("mobile: swipe", map);

2)

TouchAction touchAction = new TouchAction(driver);
         touchAction.longPress(225, 500).waitAction(3000).moveTo(225,
         250).release();
         touchAction.perform();

3) driver.swipe(225,500,225,250,3000)

Thanks in advance.

Upvotes: 0

Views: 1390

Answers (3)

Raghu K Nair
Raghu K Nair

Reputation: 3932

Here is the working solution for swipe on webapplication. I tried many solution finally tried this way it worked.

driver.context("NATIVE_APP");//This is important for TouchAction
TocuhAction action = new TouchAction(driver); //driver is AppiumDriver
action.press(startX,startY);
action.waitAction(500);  //has to be >= 500 otherwise it will fail
action.moveTo(endX,endY);
action.release();
action.perform();
//Now change back the context
driver.context("WEBVIEW_1");
//It is important to sleep for some time
TimeUnit.SECONDS.sleep(1);

Good to go..

Upvotes: 1

Jag
Jag

Reputation: 1

Swiping and scrolling will not work in IOS Simulators from IOS7. Apple removed features like swiping and scrolling, Refer https://discuss.appium.io/t/swipe-actions-are-not-performed-in-simulator/994

Upvotes: 0

Nastya
Nastya

Reputation: 11

There is a problem with swipe in iOS7 sim, btw in iOS8 I was not able to run swipe too. Just solve this problem for me by using scroll.You can set direction as "up","down","right" or "left"

HashMap scrollObject = new HashMap();{{

        scrollObject.put("direction",direction);
     }};
        iOSDriver.executeScript("mobile: scroll", scrollObject);

Upvotes: 0

Related Questions