Reputation: 52
How can i check (short code) if some string contain another in Robotframework? (like "IN" in Python)
Like this is working:
${aaax}= set variable aaa aa ba baavaa
${aaaxx}= set variable aaa aba baavaa
${aba}= set variable aba
${res1}= run keyword and return status should contain ${aaax} ${aba}
${res2}= run keyword and return status should contain ${aaaxx} ${aba}
log to console ${EMPTY}
log to console res1: ${res1}
log to console res2: ${res2}
Anyone have a better solution? like "${aba}" IN "${aaax}" or something like that working?
Upvotes: 0
Views: 792
Reputation: 3384
You can use also Set Variable If keyword combining it with in
:
${res1}= Set Variable If $aba in $aaax True False
${res2}= Set Variable If $aba in $aaaxx True False
Upvotes: 2
Reputation: 7281
One way is to use the Evaluate keyword from the BuiltIn library to simply use the Python in
operator.
*** Variables ***
${aaax} aaa aa ba baavaa
${aaaxx} aaa aba baavaa'
${aba} aba
*** Test Cases ***
String Contains
${res1}= Evaluate $aaax in $aba
${res2}= Evaluate $aba in $aaaxx
Log To Console ${res1}
Log To Console ${res2}
Upvotes: 2