The path to the driver executable must be set by the webdriver.gecko.driver system property


報這個錯,是因為你使用了selenium3+Firefox。在selenium3中,使用Firefox,需要添加驅動。

您可以從Github上下載驅動程序下載網址-  https://github.com/mozilla/geckodriver/releases/tag/v0.9.0

 

在代碼中加入

System.setProperty("webdriver.firefox.marionette","C:\\Program Files (x86)\\Mozilla Firefox\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();

C:\\Program Files (x86)\\Mozilla Firefox\\geckodriver.exe是驅動放置的位置

現在,您可以運行程序,你會得到期望的輸出。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM