Python Robot Framework Pass arguments to a function

若如初见. 提交于 2019-12-25 10:00:43

问题


I try to use this method

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)

inside robot framework file

Register Proper Data
    [Setup]    Open Browser ${web-page}    browser=${browser}
    my click  (By.PARTIAL_LINK_TEXT, "register")

but the program returns:

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?


回答1:


Why my click argument is in brackets? It should be without brackets and comma. Something like:

my click    By.PARTIAL_LINK_TEXT    register

Please ensure that there are 3-4 spaces between the function and the variables and each variable.



来源:https://stackoverflow.com/questions/45288576/python-robot-framework-pass-arguments-to-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!