Touch Actions and Mobile Web

Aha, that is a good point. We should find a way to transform the coordinates. Can you create an issue on the githug repo please?

Thanks jonahss!

I’ve created an issue in the github as requested:

Thanks & Best Regards,
Daniel.

1 Like

I’ve been getting around this by hardcoding an offset, but it’s not the most reliable method.

1 Like

hi,
actually, I have faced this kind of error when i was using like e.g. tap(button).perform()
then I used (X,Y) co-ord but Y co-ord is not correctly located on screen while X co-ord is correct so i add some offset (in my case i add 100 i.e. Y+100) then its worked for me.
But i dont think this is the reliable way to do this job.

Hi guys!
Has anybody got it resolved? Please share your results as hardcoded Y offset couldn’t be worked for different mobiles as they have different resolutions.

Eric knows another workaround, how to get this resolved.
But it also works unstable:-(

public static void tap(WebElement we) {
    Point p = we.getLocation();
    Dimension size = we.getSize();
    try {
      nativeContext();
      Point appLoc = driver.findElement(By.xpath("//UIAWebView[1]")).getLocation();
      driver.tap(1, appLoc.x + p.x + (size.width / 2), appLoc.y + p.y + (size.height / 2), 1);
    } finally {
      webContext();
    }
  }

Hi,

This doesn’t work for me:

Point appLoc = driver.findElement(By.xpath(“//UIAWebView[1]”)).getLocation();

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command.

Smth that worked on one phone. failed on another…
Is there any ideas how to get correct coordinates for tap?

@jonahss
Looks, this can be fixed in 1.3.2. When are you going to release 1.3.2?

It seems it has been fixed here:

and now is going with the new release.
Also, with the new server release this java client feature is going to be published.

Waiting for the 1.3.2 :sunny:

It’s coming! :smiley:
Running tests as we speak.

Hey, @jonahss, @SergeyTichomirov

Looks, this is no longer valid in 1.3.2:
executeScript(“mobile: swipe”, swipeObject)

Is there a way to tap, swipe and scrollTo element in webview?

Does it not work?
Have you tried

element.tap()
element.zoom()
element.pinch()
element.swipe(direction, int)

?

It something weird if it doesn’t work

executeScript(“mobile: swipe”, swipeObject);

Maybe something is broken on the server-side…

Regarding the last one I’m not sure if it still needed if above will works.
But I got the following:

e[36minfoe[39m: e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/session/cde2565af9101509c4316c499667ac90/executee[39m e[90m{“script”:“mobile: swipe”,“args”:[{“startX”:0.5,“duration”:2,“startY”:0.6,“endX”:0.5,“endY”:0.2}]}e[39m
e[36minfoe[39m: [debug] Tried to execute non-existent mobile command ‘swipe’. Most mobile commands have been ported to official client library methods. Please check your Appium library for more information and documentation
e[36minfoe[39m: [debug] Responding to client that a method is not implemented

Let me get out the error message for trying touch actions for web, like element.tap()

public LobbyPage(AppiumSwipeableDriver driver, String game) {
this.driver = driver;
this.game = game;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}

@FindBy(xpath = “//img[contains(@src, ‘image’)]”)
public MobileElement casinoTab;

And the next one is failed with:
casinoTab.tap(1,1);

java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at io.appium.java_client.pagefactory.ElementInterceptor.intercept(ElementInterceptor.java:27)
at io.appium.java_client.MobileElement$$EnhancerByCGLIB$$50f36ea9.tap()
at com.pages.LobbyPage.openCasinoTab(LobbyPage.java:67)
at com.pages.LobbyPage.openGameWithLogin(LobbyPage.java:87)
at com.run.ScreenshotMaker.gameActions(ScreenshotMaker.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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:348)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:38)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:382)
at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

I am investigating…

Is AppiumSwipeableDriver a RemoteWebDriver (not AndroidDriver/IOSDriver) subclass?

It’s a subclass from AppiumDriver