在發佈並給出解決方案之前,我已經厭倦了所有的事情,但仍然得到了相同的錯誤FireFox,Chrome & Internet Explorer。線程「main」中的異常java.lang.IllegalStateException:驅動程序可執行文件的路徑必須由webdriver.gecko.driver系統設置
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Search {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
System.getProperty("webdriver.gecko.driver",
"C:\\Users\\nitin\\Downloads\\geckodriver-v0.18.0-
win64\\geckodriver.exe");
driver.get("http://www.wikipedia.org");
WebElement link;
link = driver.findElement(By.linkText("English"));
link.click();
Thread.sleep(5000);
WebElement searchbox;
searchbox = driver.findElement(By.id("searchInput"));
searchbox.sendKeys("Software");
searchbox.submit();
Thread.sleep(5000);
driver.quit();
這應該指出OP的問題。謝謝 – DebanjanB
我也嘗試使用.getProperty,但錯誤仍然相同 –