New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java-client 5.0.1] java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement #709

Closed
luisromanbcn opened this Issue Aug 29, 2017 · 12 comments

Comments

Projects
None yet
5 participants
@luisromanbcn

luisromanbcn commented Aug 29, 2017

Description

I just tried to update the java-client version from 5.0.0-BETA9 to 5.0.1 and every time I'm trying to find an element in the screen I get this error.
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:415)

Environment

  • java client build version or git revision if you use some shapshot: 5.0.1
  • Appium server version or git revision if you use some shapshot: 1.6.6-BETA4, 1.6.5
  • Desktop OS/version used to run Appium if necessary: macOS Sierra
  • Mobile platform/version under test: Android 6.0, 5.0
  • Real device or emulator/simulator: Simulator
@TikhomirovSergey

This comment has been minimized.

Show comment
Hide comment
@TikhomirovSergey

TikhomirovSergey Aug 29, 2017

Member

@luisromanwp Could you share the code sample?

Member

TikhomirovSergey commented Aug 29, 2017

@luisromanwp Could you share the code sample?

@TikhomirovSergey

This comment has been minimized.

Show comment
Hide comment
@TikhomirovSergey

TikhomirovSergey Aug 29, 2017

Member

@luisromanwp Also. Could you check dependencies of you project? I suspect that there is some artefact which depends on Selenium version < 3.5.x

Member

TikhomirovSergey commented Aug 29, 2017

@luisromanwp Also. Could you check dependencies of you project? I suspect that there is some artefact which depends on Selenium version < 3.5.x

@luisromanbcn

This comment has been minimized.

Show comment
Hide comment
@luisromanbcn

luisromanbcn Aug 29, 2017

Here is my POM:
https://gist.github.com/luisromanwp/7781a94d9cb31567540302ca93394e80

And is failing when I try to find an element like:
driver.findElement(By.xpath("//*/android.widget.TextView[contains(@text,'Wallapop')]"))

So, @TikhomirovSergey What should I do to fix it temporally changing dependencies?

luisromanbcn commented Aug 29, 2017

Here is my POM:
https://gist.github.com/luisromanwp/7781a94d9cb31567540302ca93394e80

And is failing when I try to find an element like:
driver.findElement(By.xpath("//*/android.widget.TextView[contains(@text,'Wallapop')]"))

So, @TikhomirovSergey What should I do to fix it temporally changing dependencies?

@TikhomirovSergey

This comment has been minimized.

Show comment
Hide comment
@TikhomirovSergey

TikhomirovSergey Aug 29, 2017

Member

@luisromanwp

Could you try
mvn dependency:tree

and check the tree?

Member

TikhomirovSergey commented Aug 29, 2017

@luisromanwp

Could you try
mvn dependency:tree

and check the tree?

@luisromanbcn

This comment has been minimized.

Show comment
Hide comment
@luisromanbcn

This comment has been minimized.

Show comment
Hide comment
@luisromanbcn

luisromanbcn Aug 29, 2017

@TikhomirovSergey

Finally I made it work doing this in the POM:

https://gist.github.com/luisromanwp/7389cc9f03a722f3cee9345f3347a0cf

It was completely a dependency problem, thanks for your help :)

luisromanbcn commented Aug 29, 2017

@TikhomirovSergey

Finally I made it work doing this in the POM:

https://gist.github.com/luisromanwp/7389cc9f03a722f3cee9345f3347a0cf

It was completely a dependency problem, thanks for your help :)

@carolcruzc

This comment has been minimized.

Show comment
Hide comment
@carolcruzc

carolcruzc Oct 5, 2017

@luisromanbcn I cannot see your resolution at the pom.xml link you past here.
Could you verify it, please.
I'm taking the same problem

carolcruzc commented Oct 5, 2017

@luisromanbcn I cannot see your resolution at the pom.xml link you past here.
Could you verify it, please.
I'm taking the same problem

@luisromanbcn

This comment has been minimized.

Show comment
Hide comment
@luisromanbcn

luisromanbcn Oct 5, 2017

@carolcruzc
Here you have a new link with what I added to the POM to make it work
https://gist.github.com/luisromanbcn/cf2cab104204e41d74313e287538f2db

luisromanbcn commented Oct 5, 2017

@carolcruzc
Here you have a new link with what I added to the POM to make it work
https://gist.github.com/luisromanbcn/cf2cab104204e41d74313e287538f2db

@carolcruzc

This comment has been minimized.

Show comment
Hide comment
@carolcruzc

carolcruzc Oct 5, 2017

carolcruzc commented Oct 5, 2017

@ShriD

This comment has been minimized.

Show comment
Hide comment
@ShriD

ShriD Feb 8, 2018

I am getting the same error on Appium when trying to find element

Here is the code snippet

public static MobileElement waitForMobileElementToBeClickable(By by) { try { return (MobileElement) wait.until(ExpectedConditions.elementToBeClickable(by)); } catch(NoSuchElementException nse) { System.out.println("No such element found !"); return null; } catch(TimeoutException toe) { System.out.println("Timeout exception cought !"); return null; } }

Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement
[testng] at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:358)

ShriD commented Feb 8, 2018

I am getting the same error on Appium when trying to find element

Here is the code snippet

public static MobileElement waitForMobileElementToBeClickable(By by) { try { return (MobileElement) wait.until(ExpectedConditions.elementToBeClickable(by)); } catch(NoSuchElementException nse) { System.out.println("No such element found !"); return null; } catch(TimeoutException toe) { System.out.println("Timeout exception cought !"); return null; } }

Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement
[testng] at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:358)

@luisromanbcn

This comment has been minimized.

Show comment
Hide comment
@luisromanbcn

luisromanbcn Feb 8, 2018

@ShriD The problem is that wait.until is a Boolean and you’re trying to convert to MobileElement, you should do a findElement after the code passes the wait.until and return it

luisromanbcn commented Feb 8, 2018

@ShriD The problem is that wait.until is a Boolean and you’re trying to convert to MobileElement, you should do a findElement after the code passes the wait.until and return it

sauceaaron added a commit to sauceaaron/getting-started-with-appium that referenced this issue Feb 28, 2018

Add LocalAppiumAppTest
Update pom.xml dependency to use older Appium java-client 5.0.0 because of bug in findElementByIde with newer versions.

appium/java-client#709
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment