Hi All,
I am trying to perform a pull-down refresh in the android native app.
Kindly provide me the code snippet for this gesture.
Note
Below link, I have gone through but it doesn’t work for me.
Warm Regards,
Rahamthulla MOPURI
Hi All,
I am trying to perform a pull-down refresh in the android native app.
Kindly provide me the code snippet for this gesture.
Note
Below link, I have gone through but it doesn’t work for me.
Warm Regards,
Rahamthulla MOPURI
TouchAction t = new TouchAction(driver);
t.press(ElementOption.element(el1)).waitAction(WaitOptions.waitOptions(Duration.ofMillis(3000)))
.moveTo(ElementOption.element(el2)).waitAction(WaitOptions.waitOptions(Duration.ofMillis(2000)))
.release().perform();
Hi Tharun,
Below is my code. I followed you suggested code snippet but it doesn’t help. Kindly help me by looking into the code.
Apk file you can find in the below link:
http://search.maven.org/remotecontent?filepath=com/navercorp/pulltorefresh/sample/3.2.2/sample-3.2.2.apk
DesiredCapabilities Class
package Gestures;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;
public class BaseSampleAppForGesturePractice {
public static AndroidDriver<AndroidElement> capabilities() throws MalformedURLException {
AndroidDriver<AndroidElement> driver;
File f = new File("src");
File fs = new File(f,"sample-3.2.2.apk");
DesiredCapabilities desiredCaps = new DesiredCapabilities();
//desiredCaps.setCapability("autoGrantPermissions",true);
//desiredCaps.setCapability("appWaitActivity","com.handmark.pulltorefresh.samples");
//desiredCaps.setCapability("appActivity", "com.handmark.pulltorefresh.samples");
//desiredCaps.setCapability("appPackage", "com.handmark.pulltorefresh");
desiredCaps.setCapability(MobileCapabilityType.AUTOMATION_NAME,"uiautomator2");
desiredCaps.setCapability(MobileCapabilityType.DEVICE_NAME,"Emulator-Arshi");
desiredCaps.setCapability(MobileCapabilityType.APP,fs.getAbsolutePath());
driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"), desiredCaps);
return driver;
}
}
PullDownRefresh Class
package Gestures;
import java.net.MalformedURLException;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.touch.TouchActions;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.touch.WaitOptions;
import io.appium.java_client.touch.offset.ElementOption;
public class PullDownRefresh extends BaseSampleAppForGesturePractice {
public static AndroidDriver<AndroidElement> driver;
public static void main(String[] args) throws MalformedURLException {
driver = capabilities();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
System.out.println("Test");
driver.findElementById("android:id/text1").click();
TouchAction t = new TouchAction(driver);
WebElement el1 = driver.findElementsByClassName("android.widget.TextView").get(1);
WebElement el2 = driver.findElementsByClassName("android.widget.TextView").get(5);
t.press(ElementOption.element(el1)).waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000)))
.moveTo(ElementOption.element(el2)).waitAction(WaitOptions.waitOptions(Duration.ofMillis(2000)))
.release().perform();
}
}
hi. what is it? swipe down screen? or some element?
Hi Aleksei,
Thank you for your support.
Below is the pull-down refresh screenshot for your reference.
Thank you…!!!
pls confirm what exactly needed. e.g. is swipe from screen center to down needed? how you do it manually?
Hi Aleksei,
I am confirming that manually i will do swipe from screen centre to down.
Thank you…!!!
@Rahamthulla_Mopuri try -> https://github.com/amedvedjev/appium/blob/feature/doc-swipe_2/docs/en/writing-running-appium/tutorial/swipe-tutorial.md with “Screen swipe” example.
Aleksei,
Thank you very much for your support.
I will try it out and let you know
Hi Aleksei,
Below solution which you provided me is perfectly working.
Thank you very much for your support…!!!
Warm Regards,
Rahamthulla MOPURI