1

I get error while compiling:

public static WebDriverWait wait = null; 
wait = new WebDriverWait(driver, 120);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id(HomeScreen.tabHome_ID)));

I'm using IntelliJ IDE

Error

Error:(51, 19) java: method until in class org.openqa.selenium.support.ui.FluentWait 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>)
JeffC
  • 22,180
  • 5
  • 32
  • 55
Mohsin Awan
  • 1,176
  • 2
  • 12
  • 29

1 Answers1

2

It's probably a problem with the JRE version. If you are using maven add this to the POM file to specify the Java version (you can change the 1.8 to whatever version you are using)

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
   </plugins>        
</build>

You can also change it under File > Settings > Build, Execution, Deployment > Compiler > Java Compiler, in the Target bytecode version column.

Guy
  • 46,488
  • 10
  • 44
  • 88
  • There is no POM file in IntelliJ IDEA :( But there is some .iml file in it, Is this a project/packages configuration file? – Mohsin Awan Apr 02 '18 at 07:28
  • @MohsinAwan You can't do it (AFAIK) with the .iml file. I added another option to my answer. – Guy Apr 02 '18 at 07:49
  • Issue is with wait.until() method of wait. Can you please help me how to use the newer version of until() method or how to use the deprecated until() method? – Mohsin Awan Apr 02 '18 at 10:29
  • @MohsinAwan Did you updated all the modules? Is it the same error? – Guy Apr 02 '18 at 10:38
  • Well in an old project it is working fine. I just made a new project & copied few basic files from the old project. Now it is showing this error! – Mohsin Awan Apr 02 '18 at 10:58
  • @MohsinAwan This is not what I asked. Did you update the settings? – Guy Apr 02 '18 at 11:03
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/168038/discussion-between-guy-and-mohsin-awan). – Guy Apr 02 '18 at 11:06