Robot Framework在PATH变量

时间:2017-03-13 14:30:25

标签: automation selenium-chromedriver robotframework

我想使用Chrome进行Robot Framework自动化测试。以下是我的设置:

*User variables:*
name: webdriver.chrome.driver
value: C:\chromedriver_win32\chromedriver.exe

name: PATH
values: ......;C:\chromedriver_win32\chromedriver.exe

我的代码:

*** Settings ***

Library  BuiltIn
Library  Selenium2Library
Library  SikuliLibrary
Library  OperatingSystem

*** Variables ***
${HOST} =  VM
${URL} =  http://VM.com

${BROWSER} =  Chrome


*** Test Cases ***
Begin Web Test
    Open Browser  ${URL}   ${BROWSER}
    maximize browser window

执行命令后:pybot test.robot:

==============================================================================
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No brows
er is open
Test Case                                                             FException
 AttributeError: "'Service' object has no attribute 'process'" in <bound method
Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x000000
0003670278>> ignored
Test Case                                                             | FAIL |
Setup failed:
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Plea
se see https://sites.google.com/a/chromium.org/chromedriver/home
------------------------------------------------------------------------------

这里有什么问题?

谢谢

2 个答案:

答案 0 :(得分:5)

“chromedriver'可执行文件需要在PATH中”意味着chromedriver的 location 需要在路径中。在你的情况下,路径需要是“......; C:\ chromedriver_win32”。 PATH包含文件夹,而不是可执行文件。

答案 1 :(得分:2)

从其官方网站下载Chromedriver.exe,解压缩.exe文件并将此.exe文件复制到Python安装的scripts文件夹中,例如C:\ Python36 \ Scripts

然后,将此脚本路径添加到Environment变量中,如下所示:

Path Environment Variable

现在执行您的测试用例。