sta*_*101 10 .net c# selenium webdriver
有人可以告诉我如何在Selenium(C#)中设置firefox exe文件的路径.
我目前正在使用以下代码,但它没有按预期工作:
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
IWebDriver driver = new FirefoxDriver(profile);
Run Code Online (Sandbox Code Playgroud)
任何建议,将不胜感激.
您应该使用FirefoxBinary而不是FirefoxProfile,如下所示
FirefoxBinary binary = new FirefoxBinary(new File("path/to/binary"));
FirefoxOptions options = new FirefoxOptions();
options.setBinary(binary);
IWebDriver driver = new FirefoxDriver(options);
Run Code Online (Sandbox Code Playgroud)