On Thu, Mar 8, 2012 at 12:26 AM, kevin chong <mr.kevi...@gmail.com> wrote:
> I'm trying to run the keyword "Should Be Empty" along with "Get IP Address"
> where I would like to pass in arguments to "Get IP Address". However, Since
> "Should Be Empty" also handles arguments, it takes "Get IP Address"'s
> argument and returns that string instead.
>
> For example.
>
> ${retrieveIp}= Wait Until Keyword Succeeds 10 min 5 sec Should Not Contain
> None Get IP Address ${DUT_MAC}
>
> I guess what i'm trying to achieve is this
> while time != 10 minutes or keyword succeeds, run every 5 seconds{
> Should Not Contain (None, (Get IP Address, ${DUT_MAC}))
> }
Robot Framework does not allow chaining keyword calls like programming
languages allow chaining function calls. You must create a user
keyword that you use with Wait Until Keyword Succeeds, like this:
| ${retrieveIp}= | Wait Until Keyword Succeeds | 10 min | 5 sec | Get
Valid IP Address |
*** keywords ****
| Get Valid IP Address |
| ${ip}= | Get IP Address | ${DUT_MAC} |
| Should Not Contain | ${ip} | None |
| [Return] | ${ip} |
Haven't tested it, but barring typos it should work. If ${DUT_MAC} is
a local variable, you can of course make it an argument to `Get Valid
IP Address`.
hope this helps,
--J
On Thu, Mar 8, 2012 at 6:57 PM, kevin chong <mr.kevi...@gmail.com> wrote:
> Ah Yes! Sorry! I remember why I did not do it this way. Sometimes I want to
> pass in values that is not ${DUT_MAC} and enter it in manually. By doing it
> your method, I believe it restricts me from doing so, without creating
> another keyword for that particular device and I do not find it really
> scalable. Would you happen to have another solution this by any chance?
> thanks!
What do you mean by manually entering values? Could you provide a
concrete example that would help me understand this.
thanks,
--J
On Thu, Mar 8, 2012 at 10:18 PM, kevin chong <mr.kevi...@gmail.com> wrote:
> ${deviceIP}= Get IP Address ${deviceMAC}
> Should Not Contain ${deviceIP} None IP address could not be retrieved. False
>
> sometimes I pass in ${deviceMAC} to get IP, however sometimes I manually
> type in 00:24:23:23:23:23:24 to get the IP for those odd cases I deal with
> more devices.
>
> so if i pass in
>
> ${testIP}= Wait Until Keyword Succeeds 5 min 5 sec Get Valid IP
>
> I can't explicitly write
>
> ${testIP}= Wait Until Keyword Succeeds 5 min 5 sec Get Valid
> IP 00:24:23:23:23:23:24
>
> I was thinking of trying to add
> ${deviceMAC}= Set Variable ${DUTMAC}
> before i wait until keyword succeeds, but i dont want to have to initialize
> another variable if i dont have to. Sorry for the trouble!
This can be easily accommodated with a user keyword taking arguments:
you use it either like
| {testIP}= | Wait Until Keyword Succeeds | 5 min | 5 sec | Get
Valid IP | ${deviceMAC} |
or
| {testIP}= | Wait Until Keyword Succeeds | 5 min | 5 sec | Get
Valid IP | 00:24:23:23:23:23:24 |
and the keyword implementation is
| Get Valid IP | [Arguments] | ${macAddr} |
| | ${deviceIP}= | Get IP Address | ${macAddr} |
| | Should Not Contain | ${deviceIP}= | None |
| | [Return] | ${deviceIP} | |
Now the ${macAddr} is local to the keyword, and can be defined in the call site.
hope this helps,
--J