This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 10
May 2015
  1. I need to automate the pull and refresh in android app. I am using java.
  2. Is there any way to automate pull and refresh?
  • created

    May '15
  • last reply

    Jul '18
  • 9

    replies

  • 5.9k

    views

  • 7

    users

  • 2

    likes

  • 1

    link

1 month later

Were you able to successfully do this? did you use the swipe method or something else?
Thanks!!

1 month later

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.

8 days later

@RajeshChidambaram, Thanks your solution worked out well for pull and refresh.

  1. I have tried with same code for scrolling to top to bottom of an page. Its scroll some 2 or 3 times. After that, it throws error as
    Error Message:-
    org.openqa.selenium.WebDriverException: An error occurred while executing user supplied JavaScript

  2. It shows error in this line

js.executeScript("mobile: scroll", scrollObject);

// scroll down
WebElement elements=driver.findElement(By.className("UIACollectionCell"));
for (int second = 0;; second++) {
if(second >=60){
break;
}
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap scrollObject = new HashMap();
scrollObject.put("direction", "Down");
scrollObject.put("elements", ((RemoteWebElement) elements).getId());
js.executeScript("mobile: scroll", scrollObject);
sleep(5000);
}

  1. If you have any solution for scrolling from top to bottom of an page. Please provide a information.
5 months later

Hi all, in case you haven't figured out like me one day ago, the solution is simple. Use the swipe method. Here is an example that worked for me in a nexus 5:

driver.swipe(411,290,411,900,2000);

Thanks :slightly_smiling:

3 months later

I tried this and it worked for me

//Get the size of screen.
size = andoDriver.manage().window().getSize();
//Find swipe start and end point from screen's width and height.
//Find starty point which is at bottom side of screen.
int starty = (int) (size.height * 0.90);
//Find endy point which is at top side of screen.
int endy = (int) (size.height * 0.20);
//Find horizontal point where you wants to swipe. It is in middle of screen width.
int startx = size.width / 2;
System.out.println("starty = " + starty + " ,endy = " + endy + " , startx = " + startx);
//Swipe from Bottom to Top. driver.swipe(startx, starty, startx, endy, 3000);
Thread.sleep(10000);
//Swipe from Top to Bottom.
andoDriver.swipe(startx, endy, startx, starty, 3000);

But now I am looking for how to verify if the loader was shown.

2 years later

It’s not working for me,I applied the above solution on Google Pixel, but it fails the problem I am facing is that when the android screen load completely after the service request complete we are not getting the element from the screen, for that reason we tried to refresh the screen, spent my complete day, but fails, pleas help.