Touch Actions and Mobile Web

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

Ok. Now it is clear for me.

AppiumDriver is abstract class since 2.0.0 (java-client version). It is extended by AndroidDriver and IOSDriver. AndoidDriver generates AndroidElements and IOSDriver generates IOSElements. Both AndroidElement and IOSElement extend MobileElement.

AndroidDriver and IOSDriver have specific JsonToWebElementConverters. AppiumDriver has’t any specific converter. In your case it works like RemoteWebDriver and you receive RemoteWebElement. It is the root cause of your problem.

Why you are using AppiumSwipeableDriver (customized AppiumDriver)?

1 Like

Let me check AndroidDriver

Hmm, seems I got another error:
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: 4 milliseconds
java.lang.reflect.InvocationTargetException
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$$4ecee8af.tap()
at com.pages.LobbyPage.openCasinoTab(LobbyPage.java:64)
at com.pages.LobbyPage.openGameWithLogin(LobbyPage.java:84)
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)

This error was the cause why I was using Custom AppiumDriver with HasTouchScreen interface

Ok. Now I need help too. :frowning:
It seems that something wrong with chromedriver. I have got something similar. Android 4.4.4. I caught this error before, but I seems that problem is still here.

Caused by: org.openqa.selenium.UnsupportedCommandException: unknown command: session/0b2b54337ca29e828a1234450ec437ec/touch/perform
Command duration or timeout: 21 milliseconds
Build info: version: ‘2.43.1’, revision: ‘5163bceef1bc36d43f3dc0b83c88998168a363a0’, time: ‘2014-09-10 09:43:55’
System info: host: ‘xxx’, ip: ‘xxxx’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_20’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{app=xxxx, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=Android Emulator, platform=LINUX, desired={app=xxx, platformName=Android, deviceName=Android Emulator}, platformVersion=4.4.4, webStorageEnabled=false, locationContextEnabled=false, browserName=Android, takesScreenshot=true, javascriptEnabled=true, platformName=Android}]
Session ID: 3603990e-67e6-49df-81dc-304f1b49bdfa
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
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 io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
at io.appium.java_client.AppiumDriver.performTouchAction(AppiumDriver.java:304)
at io.appium.java_client.MultiTouchAction.perform(MultiTouchAction.java:74)
at io.appium.java_client.AppiumDriver.tap(AppiumDriver.java:331)
at io.appium.java_client.MobileElement.tap(MobileElement.java:71)
at io.appium.java_client.MobileElement$$FastClassBySpringCGLIB$$f90deb4e.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)

Actually today is the first time I use appium 1.3.2 beta.

@jonahss

Do you have any idea? It happens when driver is switched to WEBVIEV and chromedriver is started. I attempted to perform tap()

It seems that it works for iOS. But it is still invalid for Android :frowning:

It is supposed that there are fixes:

I just tried using the iPad 8.1 simulator with the exact same code that works on iPad 6.1 simulator and I’m getting an error while executing a TouchAction, driver.tap(). The error is a WebDriverException, error occurred while executing JavaScript

Am I doing something wrong here?

Anyone able to use touch actions in iOS 8? Not seeing touchstart events firing with .tap() so went to try TouchAction to no avail…

For those using Ruby, I have developed a gem that solves the situation: https://github.com/Ricardonacif/touch_action

Does anyone know if there is any work around for this issue on dot-net driver.

Because dot-net driver does not have tap method.

Current DotNetDriver is having tap method,

AppiumDriver driver = GetDriver(); // TODO Using user and capabilities.

driver.Tap(1, X, Y, 10);
driver.Tap(NoOfFingers, Xaxis, Yaxis, howLongNeedToPress);

I have tested in IOS Safari Real device, its working without issues, but before doing the tap, make sure you switch the Context to NATIVE_APP while doing the tap and after tap switch back to web View