【发布时间】:2014-04-17 07:12:35
【问题描述】:
我的 PC 上有非常旧的 FF 版本,但我无法更新它以在我的 PC 上运行 selenium 测试。同时我需要更现代的 FF 版本来运行 selenium-standalone-server。
是否有可能以某种方式指出哪个 FF(FF 目录的路径)应该使用 selenium 服务器?
【问题讨论】:
标签: selenium
我的 PC 上有非常旧的 FF 版本,但我无法更新它以在我的 PC 上运行 selenium 测试。同时我需要更现代的 FF 版本来运行 selenium-standalone-server。
是否有可能以某种方式指出哪个 FF(FF 目录的路径)应该使用 selenium 服务器?
【问题讨论】:
标签: selenium
使用您要使用的 firefox 文件夹的位置更新 PATH 变量。
【讨论】:
您可以使用 Firefox Profile 定义浏览器版本。
FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("webdriver.firefox.bin", "Binary path of Firefox");
WebDriver driver = new FirefoxDriver(fp);
或者
FirefoxBinary fb = new FirefoxBinary("Binary path of Firefox");
FirefoxProfile fp = new FirefoxProfile();
//Using fp you can set your own profile if want
WebDriver driver = new FirefoxDriver(fb, fp);
【讨论】:
Firefox 二进制文件可让您在自己喜欢的 Firefox 版本上运行测试。
按照以下步骤操作:
导入 java.io.File;导入 org.openqa.selenium.firefox.FirefoxBinary;
导入 org.openqa.selenium.firefox.FirefoxDriver;
导入 org.openqa.selenium.firefox.FirefoxProfile;私有 WebDriver 驱动程序;
FirefoxBinary binary = new FirefoxBinary(new File("C://Program Files//Mozilla Firefox26//firefox.exe"));
FirefoxProfile 配置文件 = 新的 FirefoxProfile();
driver = new FirefoxDriver(binary, profile);
从 selenium.webdriver.firefox.firefox_binary 导入 FirefoxBinary
driver = webdriver.Firefox(firefox_binary=FirefoxBinary("C://Program Files//Mozilla Firefox26//firefox.exe"))
【讨论】: