Verify text in Robotframework

邮差的信 提交于 2019-12-24 20:27:05

问题


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

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