Draw a line or text on signpad

Hi Friends, I am practicing and not getting the below case app has a signpad on entering some text then the Send button is enabled…
Steps Tried

  1. Clicked on SignPad
    MobileElement SignPad=driver.findElement(By.xpath("//android.widget.LinearLayout[@index=‘0’]"));
  2. Got the centre using get centre
    int x=var.x
    int y=var.y
    Store in 2 diff int variable
    int x1= var.x + 50
    int y1=var.y+50
  3. Used TouchAction
    Did a long press using the x coordinates of Signpad
    Then did move to new coordinates
    .longPress(PointOption.point(x, y)).perform().release();
    .moveTo(PointOption.point(newx, newy)).perform().release();

But nothing happens
Also as attached in screen shot2 the signature pad view is not found…always
Not getting as how to perform signing…

Hello @Aleksei @Zuzeac can you advise

Hi, @vsharma, try to put some wait, should work.

I use bellow method to swipe :

    public void swipeGivingExactCoord(int startX, int startY, int stopX, int stopY, int duration) {
		new TouchAction<>(driver).press(point(startX, startY)).waitAction(waitOptions(ofSeconds(duration)))
				.moveTo(point(stopX, stopY)).release().perform();
	}

it should be together (+ relese → perform!):

.longPress(PointOption.point(x, y)).moveTo(PointOption.point(newx, newy)).release().perform();

Hello @Zuzeac nothing is happening… below are the logs
I passed duration as below
WaitOptions.waitOptions(java.time.Duration.ofSeconds(5000)))

e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:{“width”:630,“height”:294}}
e[36minfoe[39m: [debug] Responding to client with success: {“status”:0,“value”:{“width”:630,“height”:294},“sessionId”:“dbd6a8c4-bb16-43aa-84df-3c0fcf8d3836”}
e[36minfoe[39m: e[37m<-- GET /wd/hub/session/dbd6a8c4-bb16-43aa-84df-3c0fcf8d3836/element/10/size e[39me[32m200e[39me[90m 13.068 ms - 98e[39m e[90m{“status”:0,“value”:{“width”:630,“height”:294},“sessionId”:“dbd6a8c4-bb16-43aa-84df-3c0fcf8d3836”}e[39m
e[36minfoe[39m: e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/session/dbd6a8c4-bb16-43aa-84df-3c0fcf8d3836/touch/performe[39m e[90m{“actions”:[{“action”:“press”,“options”:{“x”:360,“y”:360}},{“action”:“wait”,“options”:{“ms”:5000000}},{“action”:“moveTo”,“options”:{“x”:380,“y”:495}}]}e[39m
e[36minfoe[39m: [debug] Pushing command to appium work queue: [“element:touchDown”,{“x”:360,“y”:360}]
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:touchDown”,“params”:{“x”:360,“y”:360}}
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command action: touchDown
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][720,1184]
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Performing TouchDown using element? false x: 360, y: 360
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
e[36minfoe[39m: [debug] Didn’t get a new command in 60 secs, shutting down…

new TouchAction<>(driver).press(PointOption.point(x, y))
.waitAction(WaitOptions.waitOptions(java.time.Duration.ofSeconds(5000)))
.moveTo(PointOption.point(newx, newy)).perform().release();

What I see in logs is
“actions”:[{“action”:“press”,“options”:{“x”:360,“y”:360}},{“action”:“wait”,“options”:{“ms”:5000000}},{“action”:“moveTo”,“options”:{“x”:380,“y”:495}}]}
Pushing command to appium work queue: [“element:touchDown”,{“x”:360,“y”:360}]
Does that mean the Operation is not happening in Signpad?
Below is the Signpad element (shared screen shot earlier)
driver.findElement(By.xpath("//android.view.View[@index=‘0’]"));

Thanks
VS

@Aleksei

I did try as u mentioned
test.longPress(PointOption.point(x, y)).moveTo(PointOption.point(newx, newy)).perform().release();
It gives
org.openqa.selenium.interactions.InvalidCoordinatesException: The coordinates provided to an interactions operation are invalid. (WARNING: The server did not provide any stacktrace information)

Thanks
VS

@vsharma check that coordinates you provide are NOT outside of screen.

Also enable with android phone in developer mode to show touches. It will greatly helps you where are you touching.

Make sure that long press does not call submenu (replace in normal press if needed).

Try to move with small number for new X Y and see where is it moves as you expect.

Fine @Aleksei will try and revert…

@Aleksei @Zuzeac I did manage a line based on coordinates using Press / function as advised
But what I observed from log I am unclear on one thing

This line why is touch move 725,955?
New x1,y1 were 365 x1,480 y1
I had to divide 725,955 by 2 to make this work.

Thank You both of you.

e[36minfoe[39m: [debug] Pushing command to appium work queue: [“element:touchMove”,{“x”:725,“y”:955}]

Logs
e[36minfoe[39m: e[37m<-- GET /wd/hub/session/91961f02-c405-4d17-be67-b2d1128b6039/element/14/size e[39me[32m200e[39me[90m 15.799 ms - 98e[39m e[90m{“status”:0,“value”:{“width”:630,“height”:294},“sessionId”:“91961f02-c405-4d17-be67-b2d1128b6039”}e[39m
360 x
475 y
365 x1
480 y1
INFO [main] (Signature_TC.java:70)- I am here in move
e[36minfoe[39m: e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/session/91961f02-c405-4d17-be67-b2d1128b6039/touch/performe[39m e[90m{“actions”:[{“action”:“press”,“options”:{“x”:360,“y”:475}},{“action”:“moveTo”,“options”:{“x”:365,“y”:480}}]}e[39m
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command action: touchDown
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][720,1184]
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Performing TouchDown using element? false x: 360, y: 475
e[36minfoe[39m: [debug] Pushing command to appium work queue: [“element:touchMove”,{“x”:725,“y”:955}]
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}

@vsharma in your case moveTo is Relative :slight_smile: Just wonder Appium server version and Java client version?

@Aleksei the version are as following
Java Client - 6.1
Appium Server - 1.8

@Aleksei do u have notes on this relative? I need to understand…Also any links which helps to get more understanding for coordinates.

@vsharma as workaround try to use moveTo as RELATIVE for a while. your versions are quite fresh.

Thanks @Aleksei I did found 1 link https://gist.github.com/dpgraham/8b8584fd725d71561bde9e1ec863b237
But as you mentioned “try to use moveTo as RELATIVE” can u give a example…

@vsharma just relative coordinates e.g.:

       // move 10 pixels to left
        int xOffset = 10;
        int yOffset = 0;
        TouchAction action = new TouchAction((AndroidDriver) driver);
        action.press(PointOption.point(100, 100))
                .moveTo(PointOption.point(xOffset, yOffset)).release().perform();

Or use nice examples given by @mykola-mokhnach

Thank You @Aleksei for Support as usual.