繁体   English   中英

SeleniumLibrary 不接受 executable_path

[英]SeleniumLibrary doesn't accept executable_path

我正在从 pytest + Selenium 切换到机器人框架 + SeleniumLibrary + Selenium。 尽管 SeleniumLibrary 关键字旨在更易于使用,但我无法匹配从普通 Selenium 到 SeleniumLibrary 的一些简单操作。 例如,我搜索了 executable_path 并尝试了所有解决方案,但没有一个能正常工作。 使用 pytest 时,我可以创建一个 webdriver,例如:

driver = Chrome(executable_path='../drivers/chromedriver')
driver.get("https://<URL>")

使用 SeleniumLibrary 以下变体均不起作用:

*** Settings ***
Documentation     Suite description
Library  SeleniumLibrary
*** Variables ***
${URL}  https://<URL>
*** Test Cases ***
Login_test
  Open Browser  ${URL}  Chrome  executable_path="/path/to/driver/chromedriver"
*** Settings ***
Documentation     Suite description
Library           SeleniumLibrary
Library           OperatingSystem
*** Variables ***
${URL}  https://<URL>
${EXECDIR}  /path/to/driver/
*** Test Cases ***
Login_test
  Set Environment Variable  webdriver.chrome.driver  ${EXECDIR}
  Open Browser  ${URL}  Chrome
*** Settings ***
Documentation     Suite description
Library           SeleniumLibrary
*** Variables ***
${URL}  https://<URL>
${chromedriver}  /path/to/driver/chromedriver
*** Test Cases ***
Login_test
  Create Webdriver  Chrome  chrome  executable_path=${chromedriver}
  Go To ${URL}

除了手动将驱动程序的路径添加到 PATH 变量之外,还有其他解决方法吗?

我的原始代码带有引号: ${chromedriver} "/path/to/driver/chromedriver"当我将其修复为${chromedriver} /path/to/driver/chromedriver一切正常。 因此,目前唯一正确的方法是原始帖子中的最后一个选项:

*** Settings ***
Documentation     Suite description
Library           SeleniumLibrary
*** Variables ***
${URL}  https://<URL>
${chromedriver}  /path/to/driver/chromedriver
*** Test Cases ***
Login_test
  Create Webdriver  Chrome  chrome  executable_path=${chromedriver}
  Go To ${URL}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM