Run Keyword And Ignore Error with Get keyword

853 views
Skip to first unread message

GerhardH

unread,
Feb 26, 2009, 4:33:07 AM2/26/09
to robotframework-users
Hello all,

how can I use "Run Keyword And Ignore Error" or similar keywords with
any "Get xxx" keyword?

My current situation is a dialog with a variable number of text
fields, where I want to check all these text field values. My idea was
to set up a loop up to the maximal possible number of text fields,
reading each field value via:
${status}= | Run Keyword And Ignore Error | ${text}= | Get Text Field
Value | ${loopIndex}
and then aborting the loop if ${status} is not equal 'PASS'.

This construct fails, as Run Keyword And Ignore Error requires a
keyword in the next cell, but ${text}= is no keyword.

Is there any other syntax to build such a combination of "Run Keyword
xxx" and any "Get xxx" keyword? The described situation is only my
current situation; there might be other tests leading to the same
question.

If no other syntax is possible matching my idea, can you describe me a
construct for my dialog check?

Best regards
Gerhard

Thomas Klein

unread,
Feb 26, 2009, 6:51:21 AM2/26/09
to robotframework-users
One thing I could think of adhoc would be:

- define a keyword that stores the return value from "Get Text Field
Value" in a global variable instead of returning, e.g. "Store Text
Field Value"
- define a keyword that calls "${status}= | Run Keyword And Ignore
Error | Store Text Field Value" and returns both, the status and the
value
- use that keyword in a loop

Pekka Klärck

unread,
Feb 26, 2009, 9:12:45 AM2/26/09
to gerhard....@nsn.com, robotframework-users
2009/2/26 GerhardH <gerhard....@nsn.com>:

>
> how can I use "Run Keyword And Ignore Error" or similar keywords with
> any "Get xxx" keyword?
>
> My current situation is a dialog with a variable number of text
> fields, where I want to check all these text field values. My idea was
> to set up a loop up to the maximal possible number of text fields,
> reading each field value via:
> ${status}= | Run Keyword And Ignore Error | ${text}= | Get Text Field
> Value | ${loopIndex}
> and then aborting the loop if ${status} is not equal 'PASS'.

Run Keyword And Ignore Error returns both the status and the return
value of the executed keyword (if the kw passes) or the occurred error
(if the keyword failed). This is explained also in the documentation
of the keyword [1], and Run Keyword If documentation [2] has an
example of using this construct to create a simple if/else construct.

Cheers,
.peke

[1] http://robotframework.googlecode.com/svn/tags/robotframework-2.0.4/doc/libraries/BuiltIn.html#Run%20Keyword%20And%20Ignore%20Error
[2] http://robotframework.googlecode.com/svn/tags/robotframework-2.0.4/doc/libraries/BuiltIn.html#Run%20Keyword%20If

Reply all
Reply to author
Forward
0 new messages