Python Robot Framework 将参数传递给函数 [英] Python Robot Framework Pass arguments to a function
本文介绍了Python Robot Framework 将参数传递给函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用这种方法
def my_click(self, locator, info="click on button error", timeout=5):
element = self.wait_for_visibility(locator, info, timeout)
element.click()
def wait_for_visibility(self, locator, info="no error", timeout=10):
return WebDriverWait(self.get_driver(), timeout).until(
expected_conditions.visibility_of_element_located(locator), info)
内部机器人框架文件
Register Proper Data
[Setup] Open Browser ${web-page} browser=${browser}
my click (By.PARTIAL_LINK_TEXT, "register")
但程序返回:
TypeError: find_element() 最多接受 3 个参数(给出 35 个) - 其中是参数中的字母数
TypeError: find_element() takes at most 3 arguments (35 given) - which is the number of letters in the argument
为什么会这样?如何将参数传递给关键字?
Why is it happening? How to pass arguments to a keyword?
推荐答案
为什么 my click 参数在括号中?它应该没有括号和逗号.类似的东西:
Why my click argument is in brackets? It should be without brackets and comma. Something like:
my click By.PARTIAL_LINK_TEXT register
请确保函数和变量之间以及每个变量之间有3-4个空格.
Please ensure that there are 3-4 spaces between the function and the variables and each variable.
这篇关于Python Robot Framework 将参数传递给函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文