wait until keyword succeeds with users own library keyword

327 views
Skip to first unread message

Petri

unread,
May 30, 2018, 2:18:16 AM5/30/18
to robotframework-users
Hi,

can this BuiltIn keyword be used in a python library? I have a Python lib function and try like this:

  BuiltIn().wait_until_keyword_succeeds("1 min", "3 sec",  self.is_configuration_state_ready())

Here is my function:
  def is_configuration_state_ready(self):
      return self.ConfigurationDialog.Ready == True

Error:
File "C:\Programdata\Anaconda2\Lib\site-packages\robot\libraries\BuiltIn.py", line 2008, in wait_until_keyword_succeeds
  File "C:\Programdata\Anaconda2\Lib\site-packages\robot\libraries\BuiltIn.py", line 1596, in run_keyword
RuntimeError: Keyword name must be a string.

Is there some workaround, like Python function that could be used instead?
Thanks for your help!

Pekka Klärck

unread,
May 30, 2018, 3:43:08 AM5/30/18
to palap...@gmail.com, robotframework-users
Hi,

You can use WUKS with your own keywords, but you need to pass the
keyword to execute as a name only like
`BuiltIn().wait_until_keyword_succeeds("1 min", "3 sec", "Is
Configuration State Ready")`. I guess we could enhance WUKS to work
also with any callable, but at least in this case using WUKS is not a
good idea in general for various reasons:

1. WUKS creates lot of keywords internally which can increase
output.xml and log.html size considerably.
2. Your keyword "Is Configuration State Ready" can never fail. It
returns either True or False, but Robot uses exceptions to report
failures.
3. You can easily implement the same logic as WUKS does in Python
using a while loop and handling possible exceptions.

Cheers,
.peke
> --
> 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 https://groups.google.com/group/robotframework-users.
> For more options, visit https://groups.google.com/d/optout.



--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org
Reply all
Reply to author
Forward
0 new messages