java-client icon indicating copy to clipboard operation
java-client copied to clipboard

5.0.0-BETA5: parameter type conflict

Open amedvedjev opened this issue 9 years ago • 15 comments

Description

WebElement element = wait.until(ExpectedConditions.visibilityOf(el));
->
Error:(235, 38) java: method until in class org.openqa.selenium.support.ui.FluentWait<T> cannot be applied to given types;
  required: java.util.function.Function<? super org.openqa.selenium.WebDriver,V>
  found: org.openqa.selenium.support.ui.ExpectedCondition<org.openqa.selenium.WebElement>
  reason: cannot infer type-variable(s) V
    (argument mismatch; org.openqa.selenium.support.ui.ExpectedCondition<org.openqa.selenium.WebElement> cannot be converted to java.util.function.Function<? super org.openqa.selenium.WebDriver,V>)

amedvedjev avatar Mar 07 '17 09:03 amedvedjev

@amedvedjev Are you sure that it is appium issue?

TikhomirovSergey avatar Mar 07 '17 10:03 TikhomirovSergey

@TikhomirovSergey of course not :-). but it appears when i switch pom.xml to latest 5th version. Can you use mentioned in your code without issue?

now reverted back to 4th.

thanks for any idea what to check.

amedvedjev avatar Mar 07 '17 11:03 amedvedjev

@amedvedjev It is defenetely the bug of selenium. Take a look at the https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/support/ui/FluentWait.java#L34

and

https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/support/ui/FluentWait.java#L204

and now

https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/support/ui/ExpectedCondition.java#L20

It is the bug of selenium!

TikhomirovSergey avatar Mar 07 '17 11:03 TikhomirovSergey

ok. indeed. thanks for help. https://github.com/SeleniumHQ/selenium/issues/3606

amedvedjev avatar Mar 07 '17 11:03 amedvedjev

anyway the issue started appear in Selenium 3.2.0. Do we need to use buggy version of selenium?

amedvedjev avatar Mar 07 '17 11:03 amedvedjev

@amedvedjev It was not expected. You can exclude 3.2.0 at the configuration

TikhomirovSergey avatar Mar 07 '17 12:03 TikhomirovSergey

I am confused - I also have just moved up versions - to selenium 3.3.1 using the java package and I am seeing the same issue on a line of code like this - element = wait.until(ExpectedConditions.elementToBeClickable((By) identifier));

error: cannot access Function wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("toolIFrame")); required: Function<? super WebDriver,T> found: ExpectedCondition reason: cannot infer type-variable(s) T (argument mismatch; ExpectedCondition cannot be converted to Function<? super WebDriver,T>) where T,F are type-variables: T extends Object declared in method until(Function<? super F,T>) F extends Object declared in interface Wait

It looks like this was a guava issue? I don't understand what the fix is - it looks like the issues for this are closed?

amyreit avatar Mar 16 '17 01:03 amyreit

If I back down to the 3.0.0 level of selenium then i can compile again...

amyreit avatar Mar 16 '17 02:03 amyreit

@amyreit You are correct; there is somewhat of a conflict if you use the latest version of Selenium. What ended up resolving issues for me was including the latest version of guava within my pom.xml; even though I had not used it.

<dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>3.3.1</version>
</dependency>

epitosoft avatar Mar 20 '17 16:03 epitosoft

I don't have a pom file - I'm using eclipse and java.... so not sure how to make this compile work? The guava 21 is included in my classpath....

amyreit avatar Mar 20 '17 19:03 amyreit

Tried to add latest guava to my pom, didn't make a difference. Making an anonymous function as advised by http://stackoverflow.com/a/42546102 to match the signature is a workaround, but for a first time selenium user, I gotta admit I prefer to rely on the official documentation, so I downgraded to 3.0.1. Especially since I'm not sure of the usage of ExpectedConditions static methods in that context. Seems to be more of the documentation requiring an update, but having the first main doc example fail to compile doesn't get you started on the right foot.

ublanquet avatar Mar 23 '17 10:03 ublanquet

Especially since I'm not sure of the usage of ExpectedConditions static methods in that context. Its an issue in Selenium Server latest where in it should be fixed if you exclude guava from java-client and add latest guava by yourself. If possible will raise a PR and fix it at selenium end soon.

SrinivasanTarget avatar Mar 23 '17 10:03 SrinivasanTarget

Instead of com.google.guava.guava I'm using com.google.inject.juice 3.0 with selenium-java 3.4.0. My maven project builds with no problem. However if I use com.google.inject.juice 4.x then I encounter the same issues described above.

yodaqua avatar May 11 '17 08:05 yodaqua

I updated https://mvnrepository.com/artifact/com.google.guava/guava to the latest version "23.0". It fixed my problem.

NurdinKehe avatar Aug 18 '17 14:08 NurdinKehe

I too had faced the same issue and the issue got solved with adding below dependencies in my pom file:

<dependency>
         <groupId>io.appium</groupId>
         <artifactId>java-client</artifactId>
         <version>5.0.0-BETA6</version>
         <exclusions>
             <exclusion>
                 <groupId>com.google.guava</groupId>
                 <artifactId>guava</artifactId>
             </exclusion>
         </exclusions>
     </dependency>
     <dependency>
         <groupId>com.google.guava</groupId>
         <artifactId>guava</artifactId>
         <version>23.0</version>
     </dependency>
     <dependency>
         <groupId>org.seleniumhq.selenium</groupId>
         <artifactId>selenium-java</artifactId>
         <version>3.4.0</version>
     </dependency>

Issue is resolved now :) Thank you!

chethanshetty09 avatar Nov 13 '17 12:11 chethanshetty09