如何让Firefox在Mac OSX上使用Selenium WebDriver
我正在尝试为WebDriver
配置代理设置,所以我使用了以下代码….
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/");
并且在对文件执行运行后,我得到例外…
org.openqa.selenium.WebDriverException:在PATH中找不到firefox二进制文件。
确保安装了firefox。 操作系统似乎是:MAC
系统信息:os.name:’Mac OS X’,os.arch:’x86_64’,os.version:’10 .6.8’,
java.version:’1.6.0_29′
驱动程序信息:driver.version:FirefoxDriver
任何人都可以帮我解决如何以及在哪里给firefoxprofile()
路径
我相信你有几个选择:
在PATH系统变量中指定文件夹(Firefox二进制文件所在的文件夹) – 这是方法 。
或者打电话
WebDriver driver = new FirefoxDriver(new FirefoxBinary(new File("path/to/your/firefox.exe")), profile);
对于Mac,如果您通过brew cask安装FireFox,只需将其符号链接到/ Applications。
cd /Applications ln -s /Users//Applications/Firefox.app Firefox.app
这对我有用。
在我的情况下,我需要将Firefox.app从/ Users / username / Applications移动到/ Applications
对于Mac:
- 使用selenium jar 2.44.0(确保selenium服务器jar为2.44.0)
- firefox 33版( https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/33.0/mac/en-US/ )
-
在Mac的终端中,使用此命令为firefox创建配置文件:“/ Applications / Flamefox.app / Constate / MacOS / firefox-bin”-p
-
在创建配置文件时,您会看到配置文件的路径为.default, – 请注意这一点,以便在配置文件路径的代码中输入相同内容。
-
代码看起来像这样:
-
String profilePath =“/ Users / admin / Library / ApplicationSupport / Firefox / Profiles / 4duhjf19.default”;
System.out.println("profilePath: "+profilePath); File checkProfile = new File(profilePath); File[] allFolder = checkProfile.listFiles(); for (int i = 0; i < allFolder.length; i++) { if (allFolder[i].getName().endsWith(".default")) { profilePath = profilePath + allFolder[i].getName(); break; } } FirefoxProfile firefoxprofile1 = new FirefoxProfile(new File( profilePath)); System.out.println("profile path : " + firefoxprofile1); driver = new FirefoxDriver(firefoxprofile1); System.out.println("webdriver FF"); driver.manage().deleteAllCookies();
我之前遇到过这个问题,很容易解决它。
在Windows上 ,修改环境变量,将firefox path
添加到PATH
变量。
它应该在Mac上类似,只需在配置文件中导出 PATH=/my/firefox/path/bin:$PATH
。
我不确定在Mac上,但在Windows上我解决了这个问题。
确保您使用的是32位版本的nunit。 Firefox是一个32位浏览器。
我有64位Windows操作系统,但Firefox是32位浏览器。 我试图使用64位版本的nunit,它给出了“无法在PATH中使用firefox二进制文件”错误。 我通过使用32位版本的nunit解决了这个问题。 基本上,nunit文件夹中有两个exe文件,nunit.exe和nunit-x86.exe。 如果你得到这个“无法在PATH中使用firefox二进制文件”错误,很可能你需要使用32位版本的nunit – Nunit-x86.exe。
在Mac OS X上,我在尝试运行脚本时收到类似“无法找到Firefox二进制文件(os = macosx)”的WebDriver错误。
我发现我的问题是将我的Firefox应用程序重命名为“Firefox 22”。 WebDriver的东西只是“Firefox”。
由于selenium web驱动程序无法找到Firefox的.exe文件而获得此类问题。 请检查C:\ Program Files(x86)\ Mozilla Firefox中是否有exe文件,并且不要忘记设置具有java jdk路径的环境变量。 资料来源: – http://www.tech4crack.com/solved-cannot-find-firefox-binary-in-path/
- Selenium 2.48.2 + firefox 42 +浏览器未实例化
- 45000 ms后无法在端口7055上连接到主机127.0.0.1。 用FF版26.0和selenium独立jar2.39
- Selenium在一台计算机上发生了“UnreachableBrowserException / Address has in use”
- geb.driver.DriverCreationException:无法从回调创建驱动程序
- 无法使用IEDriver单击IE上的链接
- 如何调试Firefox警报框自动关闭并且无法检测Serenity BDD中的警报?
- SessionNotCreatedException:无法创建新服务:在Ubuntu上使用Selenium Grid的GeckoDriverService无法驱动Firefox
- 编写一个firefox插件并从java应用程序访问它
- Selenium Webdriver:在firefox中抑制不受信任的连接消息