Jur*_*uri 5 string robotframework
如何检查字符串是否包含机器人框架中的其他字符串?
就像是
${bool} | String Contains | Hello World | World
Run Code Online (Sandbox Code Playgroud)
Get Substring没有帮助,因为它需要一个起始索引.
Tod*_*kov 20
${source}= Set Variable this is a string
# ${contains} will be True if "is a" is a part of the ${source} value
${contains}= Evaluate "is a" in """${source}"""
# will fail if "is a" is not a part of the ${source} value
Should Be True "is a" in """${source}"""
# using a robotframework keyword from the String library
# it is actually a wrapper of python's "var_a in var_b" - the previous approaches
Should Contain ${source} is a
# as last alternative - an approach that will store
# the result in a boolean, with RF standard keywords
# ${contains} will be True if "is a" is a part of the ${source} value
${contains}= Run Keyword And Return Status Should Contain ${source} is a
Run Code Online (Sandbox Code Playgroud)
希望这个例子不言自明
我找到了另一个解决方案
${match} | ${value} | Run Keyword And Ignore Error | Should Contain | full string | substring
${RETURNVALUE} | Set Variable If | '${match}' == 'PASS' | ${True} | ${False}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23640 次 |
| 最近记录: |