TouchActions throws java.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen exception
See original GitHub issueDescription
Trying to long press a mobile element by;
TouchActions action = new TouchActions(driver);
action.longPress(element);
action.perform();
per example usage in; http://appium.io/docs/en/commands/interactions/touch/long-press/
and getting ;
java.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen
at org.openqa.selenium.interactions.touch.TouchActions.<init>(TouchActions.java:38)
at stepdefinitions.Scenarios.i_longpress_contact(Scenarios.java:137)
at ✽.I longpress contact contact(src\test\resources\features\Contacts.feature:76)
Environment
- java client build version or git revision if you use some shapshot: 7.0.0
- Appium server version or git revision if you use some shapshot: appium@1.10.1
- Desktop OS/version used to run Appium if necessary: Windows 10 Enterprise
- Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: npm: ‘6.5.0’
- Mobile platform/version under test: Android 7.1.1
- Real device or emulator/simulator: Real Device Motorola Moto E4 Plus
Other versions
<aspectj.version>1.8.10</aspectj.version>
<cucumber.version>4.2.2</cucumber.version>
<cucumber.jvm.deps.version>1.0.6</cucumber.jvm.deps.version>
<junit.version>4.12</junit.version>
<selenium.server.version>3.141.59</selenium.server.version>
<appium.java.client.version>7.0.0</appium.java.client.version>
Ecxeption stacktraces
https://gist.github.com/dokmetas/a196d76aa648b56543153e8a5659cb2c
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
ClassCastException with new Appium-java TouchActions
Solution is to use Appium TouchAction instead of Selenium TouchActions . import io.appium.
Read more >java.lang.ClassCastException: io.appium.java_client.android ...
TouchActions action throw exception: java.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.
Read more >Can't get touch actions to work : AndroidDriver cannot be cast ...
java.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen.
Read more >java.lang.ClassCastException: While performing TouchActions
java.lang.ClassCastException: class io.appium.java_client.android.AndroidDriver cannot be cast to class org.openqa.selenium.interactions.
Read more >How to use touch action in new java client 6.0.0-BETA4
... “main” java.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nurayttumer below works for my configuration;
import org.openqa.selenium.interactions.Actions;
new Actions(driver).clickAndHold(element).perform();
works with Actions API. Thanks.