如何用机器人框架定义firefox二进制路径?

时间:2017-04-28 09:56:38

标签: selenium firefox path webdriver robotframework

我是Robot Framework的新手,我尝试通过Robot Framework设置Firefox二进制文件的路径,但没有成功。我的目标是解析以下python代码:

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

 binary = FirefoxBinary('c:\path\to\binary')
 driver = webdriver.Firefox(firefox_binary=binary)

使用机器人框架:

${firefox_path}=    Evaluate    sys.modules['selenium.webdriver'].firefox.firefox_binary.FirefoxBinary(firefox_path="C:\\Users\\xxx\\ff\\firefox.exe", log_file=None)    sys
Create WebDriver    Firefox    firefox_binary=${firefox_path}
Go to    www.google.fr

但是当我运行上面的内容时,我收到以下错误消息:

WebDriverException: Message: Expected browser binary location, but unable to
find binary in default location, no 'moz:firefoxOptions.binary' capability
provided, and no binary flag set on the command line         

有没有人知道如何解决我的问题? 任何帮助将非常感激,两天试图让Firefox工作。

谢谢,耐莉

1 个答案:

答案 0 :(得分:1)

我与您分享一个解决方案:

如果您想测试Firefox扩展支持版本或便携式Firefox,您只需将木偶版设置为假

${firefox_path}= | Evaluate | sys.modules['selenium.webdriver'].firefox.firefox_binary.FirefoxBinary(firefox_path='C:\\Users\\xxx\\FirefoxPortable37\\FirefoxPortable.exe', log_file=None) | sys
${caps}= | Evaluate | sys.modules['selenium.webdriver'].common.desired_capabilities.DesiredCapabilities.FIREFOX | sys
Set To Dictionary | ${caps} | marionette=${False}
Create WebDriver | Firefox | firefox_binary=${firefox_path} | capabilities=${caps}
Go To | http://free.fr