代碼試驗:
package split;
public class locators {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty(“webdriver.chrome.driver”, “C/Users/sai/Documents/chromedriver.exe);
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com");
driver.getTitle();
}
}
錯誤:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "Invalid Character", delete this token
webdriver cannot be resolved to a variable
Syntax error on tokens, delete these tokens
Users cannot be resolved to a variable
sai cannot be resolved to a variable
Documents cannot be resolved to a variable
chromedriver cannot be resolved to a variable
WebDriver cannot be resolved to a type
ChromeDriver cannot be resolved to a type
at split.locators.main(locators.java:7)
那么如何修復這個代碼呢?
uj5u.com熱心網友回復:
就像鍵用 雙引號括起來webdriver.chrome.driver一樣,值也需要正確地用雙引號括起來。
實際上,您的代碼行將是:
System.setProperty("webdriver.chrome.driver", "C:\\Users\\sai\\Documents\\chromedriver.exe");
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/424672.html
上一篇:FileNotFoundError:[Errno2]Nosuchfileordirectory:'2022_06_02/10/22_17_06.txt'將抓取的資料寫入txt檔案時
