【问题标题】:Is there any way to point for Selenium server which FF to use?有没有办法指出要使用哪个 FF 的 Selenium 服务器?
【发布时间】:2014-04-17 07:12:35
【问题描述】:

我的 PC 上有非常旧的 FF 版本,但我无法更新它以在我的 PC 上运行 selenium 测试。同时我需要更现代的 FF 版本来运行 selenium-standalone-server。

是否有可能以某种方式指出哪个 FF(FF 目录的路径)应该使用 selenium 服务器?

【问题讨论】:

    标签: selenium


    【解决方案1】:

    使用您要使用的 firefox 文件夹的位置更新 PATH 变量。

    【讨论】:

      【解决方案2】:

      您可以使用 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);
      

      【讨论】:

        【解决方案3】:

        Firefox 二进制文件可让您在自己喜欢的 Firefox 版本上运行测试。

        按照以下步骤操作:

        1. 在您的 PC 中安装多个版本的 Firefox。
        2. 使用自定义安装确保在不同路径位置安装的 Firefox 版本

        JAVA

        导入 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);

        Python

        从 selenium.webdriver.firefox.firefox_binary 导入 FirefoxBinary

        driver = webdriver.Firefox(firefox_binary=FirefoxBinary("C://Program Files//Mozilla Firefox26//firefox.exe"))

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-06-03
          • 2015-07-24
          • 2015-07-24
          • 2019-09-07
          • 1970-01-01
          • 1970-01-01
          • 2013-05-10
          相关资源
          最近更新 更多