您需要使用Firefox的GeckoDriver。這對舊版本的Selenium 2.x並不需要,但是它需要Selenium 3.x
如果您的FF瀏覽器是32位或64位,則需要下載GeckoDriver。您還需要提供GeckoDriver和FirefoxBirnary路徑。
System.setProperty("webdriver.gecko.driver","D:\\Firefox\\geckodriver.exe");
FirefoxOptions options = new FirefoxOptions();
options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //This is the location where you have installed Firefox on your machine
FirefoxDriver driver = new FirefoxDriver(options);
driver.get("http://www.google.com");
您可以檢查此鏈接瞭解更多信息 - - 你可以用它來啓動瀏覽器的代碼示例http://www.automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/
顯示瀏覽器的配置代碼 –