Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

FluentWait Java 8 Predicates coding problem

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All, I am trying to implement a predicate instead of using an implicit wait to test a calculator application float division by 0 on an Android device. The code is as follows:




The IDE is warning me that the predicate object reference in the above code is:
a)  until(java.util.function.Function<? super org.openqa.selenium.WebDriver,java.lang.Object>) in FluentWait cannot be applied to (com.google.common.base.Predicate<org.openqa.selenium.WebDriver>)
and b) error: <anonymous com.masteringappium.appium_fmwk_with_fluent_page_objects.page_objects.CalculatorPage$1> is not abstract and does not override abstract method test(WebDriver) in Predicate

The reason why I must use an explicit wait is because the form is re-rendered and the values do not appear until after approximately 3 seconds

Many thanks in advance for any help you can give.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you using Predicate and not Function as the until method expects?

Since you have given it an apply() method, which does not exist as part of Predicate but does as part of Function, I think you've simply used the wrong interface.
 
Mark S.Raphael
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:Why are you using Predicate and not Function as the until method expects?

Since you have given it an apply() method, which does not exist as part of Predicate but does as part of Function, I think you've simply used the wrong interface.




Hi Dave, many thanks for your prompt reply. I have implemented the below example which is similar and works so I do not think that your suggestion is the reason. Please advise:


 
Mark S.Raphael
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:Why are you using Predicate and not Function as the until method expects?

Since you have given it an apply() method, which does not exist as part of Predicate but does as part of Function, I think you've simply used the wrong interface.



I changed over to function and got the same error Dave
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, I didn't see that you were using the Guava Predicate.
Might have helped to specify that.

Are you sure that second one actually compiles, as FluentWait.until expects a Function, and not a google.Predicate.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark S.Raphael wrote:
I changed over to function and got the same error Dave



Can you post that code and the full compilation errors you are getting?

If that's the case then you have an issue with libraries, or you are not compiling what you think you are.
 
Mark S.Raphael
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, Im sure. I have tried all the suggested libraries in the IDE without success
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the code that uses the Function<> interface.
And can you post (just in case) the versions of Selenium etc you are using?
 
Mark S.Raphael
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I am using selenium-java-3.7.1, and gradle
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you using the Google (Guava) version of Function?
I posted a link to the API above for until(), and it shows that unitl() expects a Function object from core Java.
https://docs.oracle.com/javase/8/docs/api/java/util/function/Function.html
 
reply
    Bookmark Topic Watch Topic
  • New Topic