[英]Java Selenium Run through Command Prompt CMD Windows Without IDE
[英]Can't run “Open Browser” with a Firefox (version 20) instance through Robot Framework IDE + Selenium
我正在寻找一种使用RIDE和Robot Framework来运行Firefox(最新版本20)的方法,以打开我喜欢的页面。 以前,这与早期的Firefox版本无关,但是现在似乎存在与Firefox 20处理配置文件的方式有关的问题。 当我尝试运行常规的“打开浏览器”命令时,会弹出Firefox,但标题中没有URL,并且没有生气。
Selenium Firefox的驱动程序似乎提供了一种定义要查找的配置文件目录的方法,但这似乎无济于事:
(给定目录对应于我通过Firefox创建的新配置文件)
尝试以下解决方案: https : //code.google.com/p/selenium/issues/detail? id = 5508希望对您有所帮助。
从这里的输入链接描述中 ,我发现:“当有自定义配置文件时,生成的配置文件路径“ newprof”可能是unicode字符串,而webdriver只接受字节串。
尝试在selenium / webdriver / firefox / firefox_profile.py中添加和删除一些行,详细信息在这里: https : //github.com/SeleniumHQ/selenium/pull/55/files#r4178907
Selenium表示您需要升级到2.32.0以使其与FF 20兼容。但是,当我这样做时,我遇到了另一个问题:它引发了“ TypeError:环境只能包含字符串”
我本人仍在寻找解决问题的方法...也许您可以升级Selenium并查看结果是否相同?
我也遇到TypeError: environment can only contain strings
当我尝试使用firefox进行robotframework时, 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将是from __future__ import unicode_literals
。 因此,当_start_from_profile_path()
调用_start_from_profile_path()
Popen(command, stdout=PIPE, stderr=STDOUT, env=self._firefox_env).communicate()
,将弹出TypeError。
解决方案:将Selenium lib更新至最新版本,或from __future__ import unicode_literals
行firefox_profile.py
转到firefox_profile.py文件并删除第一行,然后添加第二行。 (第157行)
py / selenium / webdriver / firefox / firefox_profile.py
返回self.profile_dir
返回str(self.profile_dir)
这对我来说很好
请检查是否已将geckodriver.exe文件添加到Python安装文件夹中。 默认位置在C驱动器中。 例如-C:\\ Python27。
使用最新且稳定的浏览器版本总是好的。 请确保您拥有最新的geckodriver.exe并安装Firefox ESR版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.