selenium启动Firefox报错:Cannot find firefox binary in PATH. Make sure firefox is installed

I. Description of the problem

org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: WIN10
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'DESKTOP-8EI542L', ip: '192.168.191.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: driver.version: FirefoxDriver

Second, the solution

Online solution given that it uninstall Firefox by default installation path, or write ... grinding mill chirp did not see
I think there must be more fast hardware solutions, not bow to such a low-end problem ah, I went to see Stack Overflow look great God who is way below
that looks go, too lazy screenshots, click here to view

1, I found that their code is not for me, I have the great God who changed the code changed

System.setProperty("webdriver.gecko.driver", "D:\\Sets\\WebDriver\\geckodriver-v0.25.0-win64\\geckodriver.exe");
		File pathBinary = new File("D:\\software\\Mozilla Firefox\\firefox.exe");
		FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);
		FirefoxOptions options = new FirefoxOptions();
		options.setBinary(firefoxBinary);
		// 新建一个firefox浏览器实例
		WebDriver driver = new FirefoxDriver(options);

The perfect solution! perfect!

Published 59 original articles · won praise 6 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_27009225/article/details/103897445