如何让 Firefox 在 Mac OSX 上与 Selenium WebDriver 一起工作

2022-01-16 00:00:00 selenium macos webdriver firefox java

我正在尝试为 WebDriver 配置代理设置,所以我使用了以下代码 ....

I am trying to config proxy settings for the WebDriver so I have used the following code ....

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http","207.229.122.162");
profile.setPreference("network.proxy.http_port", 3128); 
WebDriver driver = new FirefoxDriver(profile);
selenium = new WebDriverBackedSelenium(driver, "http://www.example.com/");

在对文件执行运行后,我得到了类似...的异常

and after performing run on the file I am getting exception like ...

org.openqa.selenium.WebDriverException:在 PATH 中找不到 firefox 二进制文件.

org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH.

确保已安装 Firefox.操作系统似乎是:MAC

Make sure firefox is installed. OS appears to be: MAC

系统信息:os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.6.8',

System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.6.8',

java.version: '1.6.0_29'

java.version: '1.6.0_29'

驱动信息:driver.version:FirefoxDriver

Driver info: driver.version: FirefoxDriver

谁能帮助我了解如何以及在何处提供 firefoxprofile()

Can anyone help me out regarding how and where to give path to firefoxprofile()

推荐答案

相信你有几个选择:

在 PATH 系统变量中指定文件夹(Firefox 二进制文件所在的文件夹) - 方法如下.

Either specify the folder (in which your Firefox binary is) in your PATH system variable - here's how.

或者打电话

WebDriver driver = new FirefoxDriver(new FirefoxBinary(new File("path/to/your/firefox.exe")), profile);

相关文章