Python 机器人框架don';无法从自定义库中找到自定义关键字
我试图通过运行Selenium2库来使用自定义关键字。 我已在Python 机器人框架don';无法从自定义库中找到自定义关键字,python,robotframework,Python,Robotframework,我试图通过运行Selenium2库来使用自定义关键字。 我已在.py文件中定义了此关键字: from Selenium2Library import Selenium2Library class TestLibrary(Selenium2Library): def storm_click(self, locator): submit_button = self._current_browser().find_element_by_class_name(locator)
.py
文件中定义了此关键字:
from Selenium2Library import Selenium2Library
class TestLibrary(Selenium2Library):
def storm_click(self, locator):
submit_button = self._current_browser().find_element_by_class_name(locator)
submit_button.click()
我已使用库导入将此自定义关键字导入到我的.robot
测试文件中:
*** Settings ***
Library TestLibrary.py
当我执行机器人时
robot tests/livestorm.robot
我有一个问题:
找不到名为“storm click”的关键字
你知道为什么robot框架找不到我的自定义关键字吗 您显然正在使用SeleniumLibrary的3版或更高版本。根据,必须使用
@关键字
装饰器才能将方法识别为关键字:
...
from SeleniumLibrary.base import keyword
...
class TestLibrary(Selenium2Library):
@keyword
def storm_click(...):
...
TestLibrary.py放在哪个文件夹中?您使用的是哪个版本的
Selenium2Library
?你用的是基于硒库的吗?