How to swipe on iOS 8 simulator

We have regression testing running great on iPhone5 & now i want to run those tests on the iOS simulator as part of our continues integration post build execution.
seems that the tests are failing since swipe is broken.
any idea how to workaround it in java?
Thanks…

1 Like

I have tried the below code however though the “up” & “down” gestured worked the “left” & “right” didn’t work!
any idea if:
A. This is the best practice for gestures in simulator?
B. Any idea why the code doesn’t work for left/right gestures?
C. Will the driver.swipe() method planned to be fixed for iOS simulator in future appium version?
Thanks in Advance…

public void scroll(AppiumDriver driver , String direction){
JavascriptExecutor js= (JavascriptExecutor) driver;
Map<String, String>scrollMap =new HashMap<String, String>();
scrollMap.put(“direction”, direction);
js.executeScript(“mobile: scroll”, scrollMap);
}

Hi menypeled,

Are you able to do PULL TO REFRESH… If you are able to do it. Could you please help me on that…

thank you,
Zetendra L

Hi jitendra_l,
In order to refresh you need to scroll up,
so you can either use the driver.swipe() method or use the below method & just pass it the “up” string

public void scroll(IOSDriver driver , String direction){
JavascriptExecutor js= (JavascriptExecutor) driver;
Map<String, String>scrollMap =new HashMap<String, String>();
scrollMap.put(“direction”, direction);
js.executeScript(“mobile: scroll”, scrollMap);
}

Hi menypeled,

I tried in simulator. Its not working …

thank you,
Zetendra L

does it work on real device?
if yes then it the simulator broken swipe issue.
i gave up on the simulator & use real devices.

Hi Guys

Even i searched a lot for pull down to refresh in android and IOS and found for scroll and used it to work it for pull to refresh. The following code works good for me for “Pull to Refresh” in a UIATable in IOS app.

import org.openqa.selenium.remote.RemoteWebElement;
import java.util.HashMap;

WebElement element=driver.findElement(By.className(“UIATableCell”));
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap scrollObject = new HashMap();
scrollObject.put(“direction”, “up”);
scrollObject.put(“element”, ((RemoteWebElement) element).getId());
js.executeScript(“mobile: scroll”, scrollObject);
js.executeScript(“mobile: scroll”, scrollObject);

I have added the last line twice intentionally and so the code tries to scroll down twice and there you go it give a pull to bottom and my page got refresh with the refresh symbol on top, if this does not work, try scrolling to the top of the table before trying this code.

Note: In IOS there is no getId() but it does not pop up any issue for me.