我是 Robot 框架的新手,我已经按照 此 链接中的所有设置相关步骤进行操作,但是,我遇到了一些我无法识别的错误。任何人,请帮助。
*** Settings ***
Documentation Simple example using SeleniumLibrary.
Library Selenium2Library
Library OperatingSystem
*** Variables ***
${LOGIN URL} https://www.google.com/
${BROWSER} Chrome
${EXECDIR} C:\chromedriver_win32\chromedriver.exe
*** Test Cases ***
Checking browser to login page
Setup chromedriver
Open Browser To Login Page
*** Keywords ***
Open Browser To Login Page
Open Browser ${LOGIN URL} ${BROWSER}
Setup chromedriver
Set Environment Variable webdriver.chrome.driver ${EXECDIR}
这是我得到的错误
C:\Users\sanat\AppData\Local\Programs\Python\Python36-32\Scripts\pybot.bat
Smoke.robot
======================================================================
Smoke :: Simple example using SeleniumLibrary.
=====================================================================
Checking browser to login page | FAIL |
WebDriverException: Message: 'chromedriver' executable needs to be in
PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
-------------------------------------------------------------------
Smoke :: Simple example using SeleniumLibrar | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
===============================================================
Output: C:\Users\sanat\PycharmProjects\RobotFram\output.xml
Log: C:\Users\sanat\PycharmProjects\RobotFram\log.html
Report: C:\Users\sanat\PycharmProjects\RobotFram\report.html
C:\Users\sanat\AppData\Local\Programs\Python\Python36-32\lib\runpy.py:125:
RuntimeWarning: 'robot.run' found in sys.modules after import of package
'robot', but prior to execution of 'robot.run'; this may result in
unpredictable behaviour
warn(RuntimeWarning(msg))
Process finished with exit code 1
我的 ChromeDriverPath 完全正确,我使用的是最新版本的 chrome 驱动程序。
在这里再补充一点:我的 Intellibot 也给了我 selenium 关键字(如“打开浏览器”)的编译时错误,我无法理解为什么?安装的机器人和pycharm版本:Robot Framework 3.0.2(win32上的Python 3.6.3)
原文由 Sanat 发布,翻译遵循 CC BY-SA 4.0 许可协议
正如 Bryan Oakley 强调的那样,这是一个很常见的错误,因此找到解决方案应该不会太困难。出于这个原因,我不打算回答显而易见的问题
在您的脚本中,您尝试设置 ChromeDriver 的自定义路径,这有时很有用。您尝试设置环境变量
webdriver.chrome.driver
但它不起作用,因为 Python 绑定不会检查它 是否存在 chromedriver 可执行文件。但是,可以在 chromedriver 实例化时提供可执行文件。在 Robot Framework
SeleniumLibrary
这是使用executable_path
参数完成的。这将导致以下示例: