简体   繁体   中英

Selenium WebDriver 2.53 - set Firefox executable path

I have a project with WebDriver 2.53. I am not ready to move it to 3.x. I am running Windows 7. My code is in Java.

With Selenium WebDriver 2.53, latest Firefox is not supported. I need to supply it with Firefox 44. (45 esr fails most of the time in my experience). But a system-wide installation of an old version of Firefox triggers a corporate auto-update system.

There is a portable version of Firefox 44 that one can install anywhere without affecting the system-wide Firefox. But I would need to set WebDriver to use the Firefox executable at a certain path, not in C:\\Program Files(x86)\\Mozilla Firefox.

How do I set this path? I did search bit nothing I could find online works.

Have you tried the following?

File pathToBinary = new File("C:\\user\\Programme\\FirefoxPortable\\App\\Firefox\\firefox.exe");
FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
FirefoxProfile firefoxProfile = new FirefoxProfile();       
WebDriver driver = new FirefoxDriver(ffBinary,firefoxProfile);

This is taken directly from another Stack Overflow post and I have not tried the code. Cannot find firefox binary in PATH. Make sure firefox is installed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM