【问题标题】:When i run selenium webdriver code Firefox webdriver not starting through given webaddress当我运行 selenium webdriver 代码时,Firefox webdriver 没有通过给定的网址启动
【发布时间】:2016-04-18 06:44:13
【问题描述】:

当我尝试在 Firefox 网络驱动程序上启动时,它没有启动它显示的 Firefox 默认页面

    WebDriver dr = new FirefoxDriver();
    dr.get("https://www.google.co.in/");
    dr.manage().window().maximize();

它没有开始显示 Firefox 默认页面 下面我附上输出图像截图

https://www.mozilla.org/en-US/firefox/43.0.4/firstrun/learnmore/

【问题讨论】:

  • 您使用的是哪个 webdriver 版本? 2.48.2?
  • 尝试使用较低的Firefox版本
  • 我几天前也遇到了同样的问题,这是因为您安装的 Firefox 版本。只需安装以前的版本,它就会被修复。

标签: java selenium-webdriver


【解决方案1】:

Firefox 是与 selemium 最兼容的浏览器之一,同时也是最不兼容的浏览器之一。

我这样说是因为如果你没有正确版本的 selenium 库来配合你正在运行的 firefox 版本,反之亦然,它总是会失败。

我会先尝试切换到不同版本的 Firefox。 Selenium 版本 2.48.0 支持 Firefox 版本 24-41,因此如果您的 Firefox 版本不在该范围内,则很可能是问题所在。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题。解决这个问题的方法是更新 selenium 版本。当你提到的页面即https://www.mozilla.org/en-US/firefox/43.0.4/firstrun/learnmore/在firefox启动时打开时,转到选项->插件->扩展。您将能够在那里看到错误。我得到“Forefox Webdriver 无法加载并被禁用”。

    这是在带有 selenium 2.44 的 Firefox 43 上。更新到 selenium 2.51 解决了这个问题。

    【讨论】:

      【解决方案3】:

      对不起,我还不能发表评论,但我想帮忙。当我使用集成在我的 python 脚本中的 selenium webdriver 时,我遇到了类似的问题。问题出在凭据上(尤其是在声明新的 webdriver 对象时使用 SSL 协议)。我使用的代码如下所示:

      driver = webdriver.PhantomJS(executable_path = "/opt/local/bin/phantomjs", service_args=['--ignore-ssl-errors=true'])
      

      如您所见,我使用了一个忽略 ssl 错误的密钥。这解决了我的问题,所以我不确定您使用什么平台编写代码,但希望您能找到对象的类似调用。

      我发现了人们如何处理不受信任的证书here。特别是对于 FireFox:

      //It creates firefox profile
      FirefoxProfile profile=new FirefoxProfile();
      
      // This will set the true value
      profile.setAcceptUntrustedCertificates(true);
      
      // This will open  firefox browser using above created profile
      WebDriver driver=new FirefoxDriver();
      
      driver.get("pass the url as per your requirement");
      

      希望对你有帮助!

      最好。 -彼得。

      【讨论】:

        【解决方案4】:

        试试这个..这将解决问题..

            FirefoxProfile fpi = new FirefoxProfile();
            fpi.setPreference("browser.startup.homepage_override.mstone", "ignore");
            fpi.setPreference("startup.homepage_welcome_url.additional", "about:blank");
            wd = new FirefoxDriver(fpi);
            wd.get("http://www.google.com");
        

        如果你想覆盖 firefox 的属性,那么, 1.首先找到浏览器属性列表,在地址url中输入“about:config” 2.使用,setPreference 方法来设置/分配值..

        【讨论】:

          猜你喜欢
          • 2019-02-17
          • 2023-01-17
          • 2014-10-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-08-23
          • 2015-02-28
          相关资源
          最近更新 更多