问题
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:
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.
来源:https://stackoverflow.com/questions/47469178/verify-text-in-robotframework