Run Keyword If and using regular expressions

1,038 views
Skip to first unread message

Andrew Palmer

unread,
Jan 15, 2014, 4:05:47 PM1/15/14
to robotframe...@googlegroups.com
Hi all,

I have been trying to figure out a way to use an If conditional with a regular expression, but so far haven't had any luck. I need something like this

I have a preexisting variable, lets say
${VAR}
which equals a new line separated string:
line1
line2
line3

What I would like to be able to do is something as follows:
Run Keyword If     ${VAR} == 'line2'     My_Keyword     param

And execute that keyword online if 'line2' is found in the output. I was hoping to be able to use a regexp, but I'm thinking Should Match Regexp is not working the way I want it to there.
Any ideas?

Thanks

Nikolay Ivanets

unread,
Jan 15, 2014, 5:42:32 PM1/15/14
to robotframe...@googlegroups.com
Take a look at String library: http://robotframework.googlecode.com/hg/doc/libraries/String.html?r=2.8.3

You can find various keywords to search and compare strings.

Mukesh T

unread,
Jan 23, 2014, 2:19:26 PM1/23/14
to robotframe...@googlegroups.com
hello,

>>And execute that keyword online if 'line2' is found in the output.

i think the below way should also work for you:

Run Keyword If     ${VAR.__contains__('line2')}==True     My_Keyword     param

best,
Mukesh
Reply all
Reply to author
Forward
0 new messages