【问题标题】:Can't run "Open Browser" with a Firefox (version 20) instance through Robot Framework IDE + Selenium无法通过 Robot Framework IDE + Selenium 使用 Firefox(版本 20)实例运行“打开浏览器”
【发布时间】:2013-04-09 01:13:29
【问题描述】:

我正在寻找一种方法,利用 RIDE 和 Robot Framework,运行 Firefox(版本 20 -- 最新),打开我喜欢的页面。这过去与早期的 Firefox 版本无关,但现在似乎与 Firefox 20 处理配置文件的方式有关。当我尝试运行通常的“打开浏览器”命令时,会弹出 Firefox,但标题中没有 URL,而且毫无生气。

Selenium Firefox 的驱动程序似乎提供了一种方法来定义要查找的配置文件目录,但这似乎无济于事:

(给定目录对应于我通过 Firefox 创建的新配置文件)

【问题讨论】:

    标签: windows firefox selenium selenium-webdriver robotframework


    【解决方案1】:

    试试这个解决方案: https://code.google.com/p/selenium/issues/detail?id=5508 希望能帮助到你。

    【讨论】:

      【解决方案2】:

      enter link description here,我发现:“当有自定义配置文件时,生成的配置文件路径“newprof”可能是一个 unicode 字符串,webdriver 只接受字节字符串。”

      尝试在 selenium/webdriver/firefox/firefox_profile.py 中添加和删除一些行,详细信息在这里:https://github.com/SeleniumHQ/selenium/pull/55/files#r4178907

      【讨论】:

        【解决方案3】:

        Selenium 说您需要升级到 2.32.0 以使其与 FF 20 兼容。但是,当我这样做时,我遇到了一个不同的问题:它抛出“TypeError:环境只能包含字符串”

        我自己还在寻找解决问题的方法……也许你可以升级 Selenium 看看是否有同样的结果?

        【讨论】:

          【解决方案4】:

          当我尝试使用 Firefox 的 robotsframework 时,我也遇到了TypeError: environment can only contain strings

          原因: 因为在 selenium-2.32.0-py2.7.egg 包中,文件selenium\webdriver\firefox\firefox_profile.py 将使用from __future__ import unicode_literals,所以firefox profile.path 将是unicode dict。 所以当_start_from_profile_path()调用Popen(command, stdout=PIPE, stderr=STDOUT, env=self._firefox_env).communicate()时,会弹出TypeError。

          解决方案: 将 Selenium 库更新到最新版本或删除 firefox_profile.py 中的 from __future__ import unicode_literals

          【讨论】:

            【解决方案5】:

            转到 firefox_profile.py 文件并删除第一行并添加第二行。 (第 157 行)

            py/selenium/webdriver/firefox/firefox_profile.py

            • 返回 self.profile_dir

            • 返回 str(self.profile_dir)

            这对我来说非常好

            【讨论】:

              【解决方案6】:

              请检查您是否已将 geckodriver.exe 文件添加到 Python 安装文件夹。默认位置在 C 盘。例如- C:\Python27.

              【讨论】:

                【解决方案7】:

                使用最新和稳定版本的浏览器总是好的。请确保您拥有最新的 geckodriver.exe 并安装 Firefox ESR 版本。

                【讨论】:

                  猜你喜欢
                  • 1970-01-01
                  • 2021-08-28
                  • 2017-08-01
                  • 2023-01-07
                  • 1970-01-01
                  • 2015-05-12
                  • 2020-10-20
                  • 2014-01-11
                  • 2016-10-12
                  相关资源
                  最近更新 更多