JAVA selenium——WebDriverException: Cannot find firefox binary in PATH.

问题:Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA

如下图:

JAVA selenium——WebDriverException: Cannot find firefox binary in PATH.

原因:firefox安装路径不是默认路径。

解决方法:

方法1、最简单的重新安装firefox到默认路径。          

方法2、直接用System.setPropert方法设置webdriver.firefox.bin的值

Java代码 :  

System.setProperty("webdriver.firefox.bin", "D:/Program Files (x86)/Mozilla Firefox/firefox.exe");