我正在从pytest + Selenium切换到robotframework + 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添加到PATH变量之外,是否还有其他解决方法?
发布于 2019-09-20 12:40:54
我的原始代码带有引号:${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}https://stackoverflow.com/questions/58010471
复制相似问题