Verify text in Robotframework

2019-08-17 17:29发布

I am want to verify text of an element. How to verify text is one of many strings: Such as: "Login fail" , "Error login", "Attempt fail"... ?

*** Keywords ***

Assert Warning Message

    Element Should Contain    id=session_key-login-error  "Login fail"  

1条回答
闹够了就滚
2楼-- · 2019-08-17 18:13

So I would create a list with the element that are accepted and then make a command list should contain;

Example:

@{expected_results}    Create List    your_1_acceptance_criteria_element    your_2_acceptance_criteria_element    your_3_acceptance_criteria_element
${world}=    set variable   your_element 
List Should Contain Value    @{expected_results}    ${world}

Name:List Should Contain Value Source:Collections Arguments:[ list_ | value | msg=None ]

Fails if the value is not found from list. If the keyword fails, the default error messages is does not contain value ''. A custom message can be given using the msg argument.

查看更多
登录 后发表回答