Help on run keyword if condition operators

2,557 views
Skip to first unread message

Andy Jiang

unread,
Oct 21, 2015, 8:28:10 AM10/21/15
to robotframe...@googlegroups.com
Hi,

I want to use the “Run keyword if” keyword for conditions like: 
  • if string contains substring, or 
  • If substring in string and similar
I googled about the usage of condition and so far the examples I’ve got are: “${some-value}” == “some other value” or “${some-value}” != “some other value”,  my question is are there any other operators that are available to use for more complex logical operation? I don’t want to use the Evaluate keyword to bring python expressions into the scripts unless I have no simpler choices.

Really appreciate your help!


Thanks & Regards,
Andy

Hélio Guilherme

unread,
Oct 21, 2015, 8:37:16 AM10/21/15
to yuan...@outlook.com, robotframe...@googlegroups.com
Have you tried the Strings library? You may get the functions results to variables and then test them.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

yuan...@outlook.com

unread,
Oct 21, 2015, 10:36:19 AM10/21/15
to heliox...@gmail.com, robotframe...@googlegroups.com

I did have a quick look at the string lib but most keywords seem to be about string testing, and the results would indicate the test case pass or fail itself. Anyway I'll give it another try. Thanks!

Sent by Outlook for Android

Ben Fariello

unread,
Oct 21, 2015, 8:32:25 PM10/21/15
to robotframework-users
Run Keyword If supports Pythonic conditionals right? Can you try something like this?

Run Keyword If "foo" in "foobar" Log you can use substring in string syntax
... ELSE Log you can NOT use substring in string syntax

Andy Jiang

unread,
Oct 21, 2015, 9:49:52 PM10/21/15
to bdfar...@gmail.com, robotframework-users
Cool. Tested it out and works great. Thanks a lot everyone!

Turns out it’s given clearly in the doc and I should’ve read it carefully:

The given condition is evaluated in Python as explained in Evaluating expressions, and name and *args have same semantics as with Run Keyword.


Thanks,
Andy
Reply all
Reply to author
Forward
0 new messages