Can't use .swipe() or touch actions in chrome browser java

hello i’m intern in a QA Team and i try to learn appium by myself, however swipe doesn’t want to work.
edit : – in native app it’s working but in chrome it doesn’t work i explain in last reply –

         System.out.println("--------------------------------------------------------------"
			+ "\n       step 3.0  Get the size of screen. \n"
			+ "--------------------------------------------------------");
	size = driver.manage().window().getSize();
	System.out.println("la taille de l'ecran est de : " + size + " px.\n");

	System.out.println("--------------------------------------------------------------"
			+ "\n      step 3.1   Find swipe start and end point from screen's with and height.\n"
			+ "                    Find startx point which is at bottom side of screen.\n"
			+ "--------------------------------------------------------");
	int starty = (int) (size.height * 0.80);

	System.out.println("--------------------------------------------------------------"
			+ "\n      step 3.2   Find endx point which is at top side of screen. \n"
			+ "--------------------------------------------------------");
	int endy = (int) (size.width * 0.20);

	System.out.println("--------------------------------------------------------------"
			+ "\n      step 3.3   Find horizontal point where you wants to swipe. \n"
			+ "                    It is in middle of screen width. \n"
			+ "--------------------------------------------------------");
	int startx = size.height / 2;
	System.out.println("- starty = " + starty + " ,endy = " + endy + " , startx = " + startx);

	System.out.println("--------------------------------------------------------------"
			+ "\n      step 3.4   Swipe from Bottom to Top. \n"
			+ "--------------------------------------------------------");
	driver.swipe(startx, starty, startx, endy, 3000);
	Thread.sleep(2000);

intelij said :

   step 3.0  Get the size of screen. 

the size of the screen is : (1536, 1952) px.


  step 3.1   Find swipe start and end point from screen's with and height.
                Find startx point which is at bottom side of screen.


  step 3.2   Find endx point which is at top side of screen. 


  step 3.3   Find horizontal point where you wants to swipe. 
                It is in middle of screen width. 

  • starty = 1561 ,endy = 307 , startx = 976

  step 3.4   Swipe from Bottom to Top. 

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)

if you have any idea of what i missed plz tell me :slight_smile:

i solved my problem.
i just choose direct value like :
driver.swipe(100, 255, 300, 250, 5000);
so i’m sure he clic where i want him to clic

edit :
and puts threads.sleep(); behind and after the swipe ! (very important)

i have a new problem …
i can’t do it in chrome …
in native app it’s working very well but in chrome it doesn’t work …
if you have any idea of what i missed plz tell me
my code :

    97     WebElement ele0 = (WebElement) driver.findElementByCssSelector("div#toto500");
98	//ele0.click();
99	Thread.sleep(2000);
100	TouchAction action = new TouchAction((MobileDriver) driver);
101	Thread.sleep(2000);
102	action.tap(ele0).release();
103	action.perform();
104	Thread.sleep(2000);

the click() is working
but all action fail at the perform line :
at com.emile.TestSauvegarde.TestSwipeActionTouch.swipingHorizontal(TestSwipeActionTouch.java:103)

my set up :

                @Before public void setUp() throws Exception
             	{
		    System.out.println("--------------------------------------------------------------"
				+ "\n                          set up appium   / \n"
				+ "--------------------------------------------------------");
		// set up appium
		File classpathRoot = new File(System.getProperty("user.dir"));
		File appDir = new File(classpathRoot, "../../../apps/Chrome");
		File app = new File(appDir, "chrome-47-0-2526-83-multi-android (1).apk");

		DesiredCapabilities capabilities = new DesiredCapabilities();
		capabilities.setCapability("deviceName", "HT4C2JT02122");
		capabilities.setCapability("browserName", "Chrome");
		capabilities.setCapability("platformVersion", "6.0.1");
		capabilities.setCapability("platformName", "Android");
		capabilities.setCapability("app", app.getAbsolutePath());
		System.out.println("--------------------------------------------------------------"
				+ "\n                          1 driver is launching  / \n"
				+ "--------------------------------------------------------");
		driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
		driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
		System.out.println("--------------------------------------------------------------"
				+ "\n                          2 google is launching   / \n"
				+ "--------------------------------------------------------\n\n");
		driver.get("http://172.30.6.201/testTouch/");
	}

i solved again …
i go to a native context
i execute touch action
and i go back to chrome context

1 Like

another problem with browsers and appium … the orientation landscape … where i should do this :

    	String originalContext = driver.getContext();
		driver.context("NATIVE_APP");
		((Rotatable)driver).rotate(ScreenOrientation.LANDSCAPE);
		driver.context(originalContext);