appium / appium/java-client

wait.until(java.util.function.Function<? super T,V> isTrue) is not working for AppiumFluentWait<T>

Open
#1,220 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.3k
Forks
752
Avg merge
6d 21h
Merged PRs (30d)
8

Description

Description

Trying to use the AppiumFluentWait<> class to poll for an element to appear.
It is returning a java.lang.ClassCastException: Cannot cast org.openqa.selenium.support.ui.Clock$1JreClock to org.openqa.selenium.support.ui.Clock

This seems like it could be a Selenium issue, but since I am using it with Appium, I thought it would post it here.

Environment

  • java client build version or git revision if you use some shapshot: 1.8.0_211
  • Appium server version or git revision if you use some shapshot: 1.14.1
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: v10.16.0
  • Mobile platform/version under test: iOS
  • Real device or emulator/simulator: Xcode 12.2 simulator

Code To Reproduce Issue [ Good To Have ]

FluentWait wait = new AppiumFluentWait<>(element)
.withPollingStrategy(null)
.withTimeout(Duration.ofSeconds(timeout))
.pollingEvery(Duration.ofSeconds(pollTime));
wait.until(isTrue -> element.isDisplayed());

Ecxeption stacktraces

java.lang.ClassCastException: Cannot cast org.openqa.selenium.support.ui.Clock$1JreClock to org.openqa.selenium.support.ui.Clock
at java.lang.Class.cast(Class.java:3369)
at io.appium.java_client.AppiumFluentWait.getPrivateFieldValue(AppiumFluentWait.java:121)
at io.appium.java_client.AppiumFluentWait.getClock(AppiumFluentWait.java:138)
at io.appium.java_client.AppiumFluentWait.until(AppiumFluentWait.java:231)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in io.appium.java_client.AppiumFluentWait at getPrivateFieldValue (line 121), getClock (line 138), and until (line 231), then reproduce the failure with the FluentWait code shown. Check why the Selenium JreClock cannot be cast to Clock; done means wait.until no longer raises this ClassCastException for the reported setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.