使用带有自定义关键字的 Bultin 库“等待关键字成功”

诺伯特·福加拉西

我正在编写一个自定义的机器人框架库Python我想等待自定义关键字直到成功,但我不知道如何使用自定义关键字正确调用它,我目前收到此错误:keyword '_element_should_not_have_class_name' failed after retrying for 30 seconds. The last error was: No keyword with name '_element_should_not_have_class_name' found.

我的自定义关键字如下所示:

def _element_should_not_have_class_name(self, element_locator, class_name):
    self.logger.console('Begin')
    classes = self.appiumlib.get_element_attribute(locator=Util.get_css_locator(self.locator[element_locator]), attribute='className')
    self.logger.console('Got classes: {}'.format(classes))
    self.builtin.should_not_contain(classes, class_name)

我想在它成功之前调用它的关键字:

def _wait_until_connection_succeeds(self, element_locator):
    self.builtin.wait_until_keyword_succeeds('0.5 min', '1 sec', '_element_should_not_have_class_name', element_locator, 'disabled')

如果我在参数列表中写一个函数,它会运行,但只运行一次。有什么办法可以解决这个问题?

布莱恩奥克利

错误告诉您问题所在,没有名为 的关键字_element_should_not_have_class_nameRobot 无法识别_以关键字开头的函数请参阅机器人框架用户指南中的哪些方法被视为关键字

解决方法:去掉函数名的前导下划线。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章