【发布时间】:2020-02-18 11:01:20
【问题描述】:
我想在机器人框架库中使用 selenium webdriver 方法。
def custom_go_to
driver = BuiltIn().get_library_instance('SeleniumLibrary')
driver.go_to(url)
自定义库中的上述代码工作正常,但我想在 robotsframework 内置库的位置使用 selenium 方法。 当我尝试使用 driver.get(url) 它说
'SeleniumLibrary' object has no attribute 'get'
我创建的自定义库 ERP.py 的样子
class ERP:
@keyword
def custom_go_to(self, url):
driver = BuiltIn().get_library_instance('SeleniumLibrary')
driver.get(url)
测试用例看起来像
***Settings***
Library SeleniumLibrary
Library path_to_lib/ERP.py
*** Variable ***
${BROWSER} | chrome
${URL} | facebook.com
***Test Cases***
Open the browser using an inbuilt keyword and go to a given URL using custom go to using EventFiringWebDriver.
Open Browser | about:blank | ${BROWSER}
Custom Go To | ${URL}
如何在机器人框架库中使用 Selenium webdriver 方法?
【问题讨论】:
-
不知道您想在这里实现什么,但最新的
SeleniumLibrary没有Get关键字...请使用现有关键字重试。 -
我想使用robotframework 库中的所有Selenium 关键字。就像我们通常只在 Python 中使用 Selenium 时所做的那样。
-
不过,
SeleniumLibrary中没有Get关键字... -
感谢您指出我,我刚刚更新了问题。我想使用 webdriver 方法。 :)
-
这里有一个相当不错的 Python 和 webdriver 教程:selenium-python.readthedocs.io/…
标签: python selenium robotframework