我有Eclipse OpenJDK11 + Gradle2.1.1项目。
我在项目属性上选择11(BETA)作为Java编译器版本。 那就是.settings \ org.eclipse.jdt.core.prefs是
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
email = "ur_email"
pwd = "ur_pwd"
driver = webdriver.Chrome()
act = ActionChains(driver)
driver.get ('https://www.linkedin.com/')
login_email = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "login-email"))
)
login_password = driver.find_element_by_id('login-password')
submit1 = driver.find_element_by_id('login-submit')
login_email.send_keys(email)
login_password.send_keys(pwd)
submit1.click()
searchfield = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@role='combobox']")))
searchfield.click()
searchKeywordXpath = "//span[text()='People']"
searchKeyword = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, searchKeywordXpath)))
searchKeyword.click()
btnAllFilterXpath = "//span[@class='artdeco-button__text' and text()='All Filters']"
btnAllFilter = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, btnAllFilterXpath)))
btnAllFilter.click()
# just debug code: wait to see the right page appear or not
time.sleep(10)
但是我编辑了build.gradle并保存了它,然后属性更改为1.8。 .settings \ org.eclipse.jdt.core.prefs:
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.source=11
这则Eclipse警告消息出现了
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.source=1.8
我试图将其添加到build.gradle中。但这没用。
The compiler compliance specified is 1.8 but a JRE 11 is used
如何永久修复JDK版本?
答案 0 :(得分:0)
在您的build.gradle
中,添加
sourceCompatibility = 11
targetCompatibility = 11