如何在机器人框架中设置路径Chrome驱动程序? [英] How to set path chrome driver in robot framework?
问题描述
现在,我设置路径变量
path : D:..;C:\Program Files\Google\Chrome\Application
Chrome : C:\Program Files\Google\Chrome\Application\chromedriver.exe
我可以在命令行中调用open Chrome
.
I can call open Chrome
in command line.
但是在RIDE
失败:WebDriverException:消息:未知错误:Chrome未能 开始:崩溃(驱动程序信息:chromedriver = 2.13.307647 (5a7d0541ebc58e69994a6fb2ed930f45261f3c29),平台= Windows NT 6.1 SP1 x86)
FAIL : WebDriverException: Message: unknown error: Chrome failed to start: crashed (Driver info: chromedriver=2.13.307647 (5a7d0541ebc58e69994a6fb2ed930f45261f3c29),platform=Windows NT 6.1 SP1 x86)
推荐答案
您需要chromeDriver而不是Chrome. 首先下载chrome驱动程序.
You need chromeDriver not Chrome. Start by downloading the chrome driver.
https://sites.google.com/a/chromium.org/chromedriver/下载
将其放在测试可以访问的位置(例如,相对于测试的bin文件夹).
Put it somewhere that your test can access (for example a bin folder relative to your tests).
现在,您需要设置环境变量以指向chrome驱动程序.
Now you need to set the environment variable to point the chrome driver.
您可以从测试外部(例如,作为桌面的全局设置)或从测试设置进行此操作.
You can do it from outside the test (for example, as a global setting for your desktop), or from your test setup.
从测试之外
只需将环境变量webdriver.chrome.driver设置为指向可执行文件即可.
Just set the environment variable webdriver.chrome.driver to point the executable.
(控制面板->系统->编辑系统环境变量)
(Control Panel -> System -> Edit the system environment variables)
从测试内部
如果您使用的是jython,则需要创建一个小型Java库来为您完成
If you're using jython, you need to create a small java library to do that for you
public void setSystemProperty(String key, String value) {
System.getProperties().setProperty(key,value);
}
并在测试中使用它
Prepare Selenium Driver
Set System Property webdriver.chrome.driver ${EXECDIR}/chromedriver.exe
如果您使用的是Python,则可以使用OperatingSystem库
If you're using Python, you can use the OperatingSystem library
*** Settings ***
Library OperatingSystem
Suite Setup Setup chromedriver
*** Keywords ****
Setup chromedriver
Set Environment Variable webdriver.chrome.driver ${EXECDIR}/chromedriver.exe
这篇关于如何在机器人框架中设置路径Chrome驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!