[URGENT] - Not able to Perform Swipe since update 1.3

Hi All,

I am new to Appium, I am trying to swipe my app using below code but It returns the following error to me… Please do the needful asap.

My Code

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class ESFile {
    public static RemoteWebDriver driver = null;
    
    @BeforeTest
      public void beforeTest() {
          DesiredCapabilities capabilities = new DesiredCapabilities();
          capabilities.setCapability("appium-version", "1.3.4");
          capabilities.setCapability("platformName", "Android");
          capabilities.setCapability("platformVersion", "5.0");
          capabilities.setCapability("deviceName", "Nexus 5");
          capabilities.setCapability("appPackage", "com.estrongs.android.pop");
          capabilities.setCapability("appActivity", "com.estrongs.android.pop.view.FileExplorerActivity");
          try {
              driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
          } catch (MalformedURLException e1) {
                        e1.printStackTrace();
          }
          driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);

      }

      @AfterTest
      public void afterTest() {
          driver.quit();
      }
        
  @Test
  public void sample() throws InterruptedException {
      Thread.sleep(4000);
      swipe(1000.0,1010.0,100.0,1050.0,1.0);
        Thread.sleep(2000);
        swipe(1000.0,1010.0,100.0,1050.0,1.2);
        Thread.sleep(2000);
      driver.findElement(By.name("Xender")).click();
      System.out.println("done");
  }
  public void swipe(double sx,double sy,double ex,double ey,double d)
    {
     JavascriptExecutor js = (JavascriptExecutor) driver;
     HashMap<String, Double> swipeObj = new HashMap<String, Double>();
     swipeObj.put("touchCount",1.0);
     swipeObj.put("startX", sx);
     swipeObj.put("startY", sy);
     swipeObj.put("endX", ex);
     swipeObj.put("endY", ey);
     swipeObj.put("duration", d);
     js.executeScript("mobile: swipe", swipeObj);
        
    }
  
}

Error

FAILED: sample
org.openqa.selenium.WebDriverException: Not yet implemented. Please help us: http://appium.io/get-involved.html (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10 milliseconds
Build info: version: ‘2.44.0’, revision: ‘76d78cf’, time: ‘2014-10-23 20:02:37’
System info: host: ‘I.local’, ip: ‘172.16.45.40’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.10.2’, java.version: ‘1.8.0_25’
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{appPackage=com.estrongs.android.pop, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=Nexus 5, platform=LINUX, appActivity=com.estrongs.android.pop.view.FileExplorerActivity, desired={appPackage=com.estrongs.android.pop, appActivity=com.estrongs.android.pop.view.FileExplorerActivity, appium-version=1.3.4, platformVersion=5.0, platformName=Android, deviceName=Nexus 5}, appium-version=1.3.4, platformVersion=5.0, webStorageEnabled=false, locationContextEnabled=false, browserName=Android, takesScreenshot=true, javascriptEnabled=true, platformName=Android}]
Session ID: 66f1562b-eeb1-4087-a455-9c1475273bc0
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:508)
at sneerglaw.ESFile.swipe(ESFile.java:62)
at sneerglaw.ESFile.sample(ESFile.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

Hi @Muhammed_Yusuf,

The mobile: swipe command was deprecated starting from Appium 1.x. Swiping is now done by using TouchActions and driver.swipe(). For example, since you’re doing an Android test, you should instantiate the driver by using the AndroidDriver constructor. As an example:

AndroidDriver driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), capabilities);
//Method 1: Swipe from pixel position (100, 100) to pixel position (100, 200) across 4000 milliseconds
driver.swipe(100, 100, 100, 200, 4000);
//Method 2: Swipe from (100, 100) to (100, 200) using TouchAction:
TouchAction action = new TouchAction(driver);
action.press(100, 100).moveTo(100, 200).release().perform();

Make sure the Java client is in your project’s build dependencies, as these APIs are available through those libraries. The Javadocs are located here.

This code was written assuming you were using Appium 1.3.4 at least.

3 Likes

Hi @awang

cool man… working fine… thanks, thanks alot… :+1:

From where I can download Appium JARs which support methods like swipe , zoom and a lot more.???

Hi @iRANG_QA ,

You can get those jar files from the following link , https://search.maven.org/#search|ga|1|g%3Aio.appium%20a%3Ajava-client

OKAY…thanks a lot…I have integrated but now getting “yet not implemented” error:(

The most common way to get the jars is through maven. If you’re familiar with maven, you can add this dependency element to your pom.xml file:

<dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>2.0.0</version>
</dependency>

A “not yet implemented” error sounds like something the Appium server sends. In this case, you might have to upgrade your Appium server. If you’re using Appium by source, you can try upgrading by checking out a 1.3.x version of Appium.

git checkout v1.3.5
2 Likes

Thank you. For me it is solved.

Sir how to find pixel position for these.??

Hey thanks. but touch action still not working for me. Swipe is working but it says deprecated