Issue
I'm using Maven and Intellij, project set for jdk-12.0.2, maven in pom 1.8 and when trying to run this code :
WebDriverWait wait = new WebDriverWait(driver, 5);
WebElement el = wait.until(ExpectedConditions.elementToBeClickable(By.linkText("https://poczta.wp.pl")));
I get :
Error:(37, 30) java: cannot access java.util.function.Function class file for java.util.function.Function not found
Pointing to 'wait'
Tried changing maven in pom from 1.7 to 1.8. > Invalidate cache/Restart
Solution
Given you have maven
tag my expectation is that your project is being managed by Maven hence built by Maven Compiler Plugin so your IDE language level settings might derive from what is defined in the pom.xml
I would recommend setting project language level in:
Maven pom.xml file like:
<properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties>
In Idea on Project Properties page you can choose the Language Level for each module
More information:
- Selenium Webdriver Tutorial with JAVA: How to set up a TestNG maven based project from scratch
- stop IntelliJ IDEA to switch java language level every time the pom is reloaded (or change the default project language level)
Answered By - Dmitri T
Answer Checked By - Cary Denson (JavaFixing Admin)