[英]'Error: java: cannot access java.util.function.Function' - while trying to use WebDriverWait
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 :我正在使用 Maven 和 Intellij,为 jdk-12.0.2 设置的项目,pom 1.8 中的 maven 以及尝试运行此代码时:
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
错误:(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.尝试将 pom 中的 maven 从 1.7 更改为 1.8。 >
Invalidate cache/Restart
>
Invalidate cache/Restart
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 鉴于您具有
maven
标签,我的期望是您的项目由Maven管理,因此由Maven编译器插件构建,因此您的IDE语言级别设置可能源自pom.xml中定义的内容。
I would recommend setting project language level in: 我建议在以下位置设置项目语言级别:
Maven pom.xml file like: Maven pom.xml文件如下:
<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: 更多信息:
I was having same problem, created project using JDK 11 but project setting was still using Language 7 (Ctrl + Shift + Alt + S)我遇到了同样的问题,使用 JDK 11 创建项目,但项目设置仍在使用语言 7(Ctrl + Shift + Alt + S)
Using selenium version 3.141.59使用硒版本 3.141.59
Below were my original settings以下是我的原始设置
Got it fixed by得到它修复
Adding below to pom.xml inside build section but after pluginManagement在构建部分的pom.xml中添加以下内容,但在 pluginManagement 之后
<plugins><plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>8</source> <target>8</target> </configuration>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.