question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TouchActions throws java.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen exception

See original GitHub issue

Description

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:closed
  • Created 5 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
dokmetascommented, Mar 11, 2019

@nurayttumer below works for my configuration;

import org.openqa.selenium.interactions.Actions;

new Actions(driver).clickAndHold(element).perform();

2reactions
dokmetascommented, Feb 11, 2019

works with Actions API. Thanks.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found