在selenium启动firefox浏览器时,出现异常:
Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: XP
原因是无法找到firefox浏览器
解决办法有两个:
1.firefox卸载,重新安装到默认路径
2.不卸载,我们只要在WebDriver driver = new FirefoxDriver(); 前面指定我们浏览器的具体信息即可:
System.setProperty("webdriver.firefox.bin","D:\\Mozilla Firefox\\firefox.exe"); (这个斜杠要打两个,作为转义字符)
WebDriver driver = new FirefoxDriver();