I wrote a for loop within robot framework, I need it to execute until certain conditions are met. I can't find a built in key word that does this efficiently. Any help would be appreciated.
:FOR | ${index} | IN RANGE | 100 VR button pressed sleep | 1 sec ${micState}= | Devaluate | signals[UISpeechService][micState][value][mode] ${VoiceRecognition}= | Devaluate | signals[UISpeechService][voiceRecognition][value][state] ${DialogActive}= | Devaluate | signals[UISpeechService][vrDialogActive][value][state] sleep | 1 sec should be equal | ${micState} | "open" should be equal | ${VoiceRecognition} | "on" should be equal | ${DialogActive} | true
so basically this presses the VR button, evaluates signals from another program, then compares those values to what they should be.
This will continue until the values compared are all equal.
The problem that is occuring is that if at any point the values are not equal it fails the test and ends the testcase. Or if they are all true after the first iteration, it will continue to do the loop 100 times.
How do I get it to exit the loop as soon as the three conditions are equal? While also continuing the loop if they are not equal.
On Fri, Nov 2, 2012 at 1:27 AM, Drewcasket <drewcasket...@gmail.com> wrote:
> I wrote a for loop within robot framework, I need it to execute until
> certain conditions are met. I can't find a built in key word that does
> this efficiently. Any help would be appreciated.
> :FOR | ${index} | IN RANGE | 100
> VR button pressed
> sleep | 1 sec
> ${micState}= | Devaluate |
> signals[UISpeechService][micState][value][mode]
> ${VoiceRecognition}= | Devaluate |
> signals[UISpeechService][voiceRecognition][value][state]
> ${DialogActive}= | Devaluate |
> signals[UISpeechService][vrDialogActive][value][state]
> sleep | 1 sec
> should be equal | ${micState} | "open"
> should be equal | ${VoiceRecognition} | "on"
> should be equal | ${DialogActive} | true
> so basically this presses the VR button, evaluates signals from another
> program, then compares those values to what they should be.
> This will continue until the values compared are all equal.
> The problem that is occuring is that if at any point the values are not
> equal it fails the test and ends the testcase. Or if they are all true
> after the first iteration, it will continue to do the loop 100 times.
> How do I get it to exit the loop as soon as the three conditions are
> equal? While also continuing the loop if they are not equal.
> Thank you
> --
> You received this message because you are subscribed to the Google Groups
> "robotframework-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/robotframework-users/-/UIQAP6vUDQUJ.
> To post to this group, send email to robotframework-users@googlegroups.com
> .
> To unsubscribe from this group, send email to
> robotframework-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/robotframework-users?hl=en.
-- *------------------------------*
*Warm Regards,
GAURAV S. DEORE.*
:FOR | ${index} | IN RANGE | 100 VR button pressed sleep | 1 sec ${micState}= | Devaluate | signals[UISpeechService][micState][value][mode] ${VoiceRecognition}= | Devaluate | signals[UISpeechService][voiceRecognition][value][state] ${DialogActive}= | Devaluate | signals[UISpeechService][vrDialogActive][value][state] sleep | 1 sec Run Keyword If | ("${micState}"=="open") and ("${VoiceRecognition}=="on") and ("${DialogActive}"=="true") | Exit For Loop Run Keyword If | ${index} == 99 | Fail | Conditions not met - micState:${micState} VoiceRecognition:${VoiceRecognition} DialogActive:${DialogActive}
Note that the index in the index check must be one less than the range. This would only allow 99 iterations to meet condidtion not 100. Checking the value of a loop counter outside of the loop is a no-no in some languages but I think its OK here.
Thanks for the help!! I was unaware that you could use the "and" "or" conjunctions within robot framework. I suppose reading the included userguide would put a stop to my postings lol. Once again thanks for the help!!
On Thursday, November 1, 2012 3:57:27 PM UTC-4, Drewcasket wrote: > I wrote a for loop within robot framework, I need it to execute until > certain conditions are met. I can't find a built in key word that does > this efficiently. Any help would be appreciated.
> :FOR | ${index} | IN RANGE | 100 > VR button pressed > sleep | 1 sec > ${micState}= | Devaluate | > signals[UISpeechService][micState][value][mode] > ${VoiceRecognition}= | Devaluate | > signals[UISpeechService][voiceRecognition][value][state] > ${DialogActive}= | Devaluate | > signals[UISpeechService][vrDialogActive][value][state] > sleep | 1 sec > should be equal | ${micState} | "open" > should be equal | ${VoiceRecognition} | "on" > should be equal | ${DialogActive} | true
> so basically this presses the VR button, evaluates signals from another > program, then compares those values to what they should be.
> This will continue until the values compared are all equal.
> The problem that is occuring is that if at any point the values are not > equal it fails the test and ends the testcase. Or if they are all true > after the first iteration, it will continue to do the loop 100 times.
> How do I get it to exit the loop as soon as the three conditions are > equal? While also continuing the loop if they are not equal.
You might also want to consider the Wait Until Keyword Succeeds (see Builtin Library) to handle this. That would give you time-based control over how long to wait and how often to re-check, which could be more feasible for what you are testing.
Also, the 'and' and 'or' support comes from the Evaluate keyword, which simply uses the Python/Jython eval() function. So, the support for those conjunctions comes from Python, not RF.
On Friday, November 2, 2012 9:24:19 AM UTC-4, Drewcasket wrote:
> Thanks for the help!! I was unaware that you could use the "and" "or" > conjunctions within robot framework. I suppose reading the included > userguide would put a stop to my postings lol. Once again thanks for the > help!!
> Drew > On Thursday, November 1, 2012 3:57:27 PM UTC-4, Drewcasket wrote:
>> I wrote a for loop within robot framework, I need it to execute until >> certain conditions are met. I can't find a built in key word that does >> this efficiently. Any help would be appreciated.
>> :FOR | ${index} | IN RANGE | 100 >> VR button pressed >> sleep | 1 sec >> ${micState}= | Devaluate | >> signals[UISpeechService][micState][value][mode] >> ${VoiceRecognition}= | Devaluate | >> signals[UISpeechService][voiceRecognition][value][state] >> ${DialogActive}= | Devaluate | >> signals[UISpeechService][vrDialogActive][value][state] >> sleep | 1 sec >> should be equal | ${micState} | "open" >> should be equal | ${VoiceRecognition} | "on" >> should be equal | ${DialogActive} | true
>> so basically this presses the VR button, evaluates signals from another >> program, then compares those values to what they should be.
>> This will continue until the values compared are all equal.
>> The problem that is occuring is that if at any point the values are not >> equal it fails the test and ends the testcase. Or if they are all true >> after the first iteration, it will continue to do the loop 100 times.
>> How do I get it to exit the loop as soon as the three conditions are >> equal? While also continuing the loop if they are not equal.
I'm getting this error saying that true is undefined. KEYWORD: *${micState} = OnTheDLib.D Evaluate* signals[UISpeechService][micState][value][mode] Expand All<javascript:expandAllChildren('s1-s1-t1-k1-k1-k1-k4')> Documentation:
DEvaluate(parameter) takes a string parameter (e.g. signals[Media][nowPlaying][value][title]) and returns the looked-up value of that parameter. Start / End / Elapsed: 20121102 12:22:02.870 / 20121102 12:22:03.073 / 00:00:00.203 12:22:03.073 INFO ${micState} = "open" - KEYWORD: *${VoiceRecognition} = OnTheDLib.D Evaluate* signals[UISpeechService][voiceRecognition][value][state] Expand All<javascript:expandAllChildren('s1-s1-t1-k1-k1-k1-k5')> Documentation:
DEvaluate(parameter) takes a string parameter (e.g. signals[Media][nowPlaying][value][title]) and returns the looked-up value of that parameter. Start / End / Elapsed: 20121102 12:22:03.073 / 20121102 12:22:03.073 / 00:00:00.000 12:22:03.073 INFO ${VoiceRecognition} = "on" - KEYWORD: *${DialogActive} = OnTheDLib.D Evaluate* signals[UISpeechService][vrDialogActive][value][state] Expand All<javascript:expandAllChildren('s1-s1-t1-k1-k1-k1-k6')> Documentation:
DEvaluate(parameter) takes a string parameter (e.g. signals[Media][nowPlaying][value][title]) and returns the looked-up value of that parameter. Start / End / Elapsed: 20121102 12:22:03.073 / 20121102 12:22:03.089 / 00:00:00.016 12:22:03.089 INFO ${DialogActive} = true + KEYWORD: *BuiltIn.Sleep* 1 sec Expand All<javascript:expandAllChildren('s1-s1-t1-k1-k1-k1-k7')> Documentation:
Pauses the test executed for the given time. Start / End / Elapsed: 20121102 12:22:03.089 / 20121102 12:22:04.089 / 00:00:01.000 - *KEYWORD: ${signals ok} = BuiltIn.Evaluate* (${micState}=="open") and (${VoiceRecognition}=="on") and ${DialogActive}==true Expand All<javascript:expandAllChildren('s1-s1-t1-k1-k1-k1-k8')> Documentation:
Evaluates the given expression in Python and returns the results. Start / End / Elapsed: 20121102 12:22:04.089 / 20121102 12:22:04.104 / 00:00:00.015 12:22:04.104 FAIL Evaluating expression '("open"=="open") and ("on"=="on") and true==true' failed: NameError: name 'true' is not defined
Everything is evaluating correctly so ${signals ok} should come back as True, instead I get the above error. What am I doing wrong?
On Thursday, November 1, 2012 3:57:27 PM UTC-4, Drewcasket wrote: > I wrote a for loop within robot framework, I need it to execute until > certain conditions are met. I can't find a built in key word that does > this efficiently. Any help would be appreciated.
> :FOR | ${index} | IN RANGE | 100 > VR button pressed > sleep | 1 sec > ${micState}= | Devaluate | > signals[UISpeechService][micState][value][mode] > ${VoiceRecognition}= | Devaluate | > signals[UISpeechService][voiceRecognition][value][state] > ${DialogActive}= | Devaluate | > signals[UISpeechService][vrDialogActive][value][state] > sleep | 1 sec > should be equal | ${micState} | "open" > should be equal | ${VoiceRecognition} | "on" > should be equal | ${DialogActive} | true
> so basically this presses the VR button, evaluates signals from another > program, then compares those values to what they should be.
> This will continue until the values compared are all equal.
> The problem that is occuring is that if at any point the values are not > equal it fails the test and ends the testcase. Or if they are all true > after the first iteration, it will continue to do the loop 100 times.
> How do I get it to exit the loop as soon as the three conditions are > equal? While also continuing the loop if they are not equal.
I got it figured out. The program that I'm testing is returning a boolean value of true, but python needs to recognize it as True(with a capital T). Now I have to incorporate some code to receive true and change it to True before checking the ${signals ok}.
On Thursday, November 1, 2012 3:57:27 PM UTC-4, Drewcasket wrote: > I wrote a for loop within robot framework, I need it to execute until > certain conditions are met. I can't find a built in key word that does > this efficiently. Any help would be appreciated.
> :FOR | ${index} | IN RANGE | 100 > VR button pressed > sleep | 1 sec > ${micState}= | Devaluate | > signals[UISpeechService][micState][value][mode] > ${VoiceRecognition}= | Devaluate | > signals[UISpeechService][voiceRecognition][value][state] > ${DialogActive}= | Devaluate | > signals[UISpeechService][vrDialogActive][value][state] > sleep | 1 sec > should be equal | ${micState} | "open" > should be equal | ${VoiceRecognition} | "on" > should be equal | ${DialogActive} | true
> so basically this presses the VR button, evaluates signals from another > program, then compares those values to what they should be.
> This will continue until the values compared are all equal.
> The problem that is occuring is that if at any point the values are not > equal it fails the test and ends the testcase. Or if they are all true > after the first iteration, it will continue to do the loop 100 times.
> How do I get it to exit the loop as soon as the three conditions are > equal? While also continuing the loop if they are not equal.
On Friday, November 2, 2012 12:58:09 PM UTC-4, Drewcasket wrote:
> I got it figured out. The program that I'm testing is returning a boolean > value of true, but python needs to recognize it as True(with a capital T). > Now I have to incorporate some code to receive true and change it to True > before checking the ${signals ok}.
> On Thursday, November 1, 2012 3:57:27 PM UTC-4, Drewcasket wrote:
>> I wrote a for loop within robot framework, I need it to execute until >> certain conditions are met. I can't find a built in key word that does >> this efficiently. Any help would be appreciated.
>> :FOR | ${index} | IN RANGE | 100 >> VR button pressed >> sleep | 1 sec >> ${micState}= | Devaluate | >> signals[UISpeechService][micState][value][mode] >> ${VoiceRecognition}= | Devaluate | >> signals[UISpeechService][voiceRecognition][value][state] >> ${DialogActive}= | Devaluate | >> signals[UISpeechService][vrDialogActive][value][state] >> sleep | 1 sec >> should be equal | ${micState} | "open" >> should be equal | ${VoiceRecognition} | "on" >> should be equal | ${DialogActive} | true
>> so basically this presses the VR button, evaluates signals from another >> program, then compares those values to what they should be.
>> This will continue until the values compared are all equal.
>> The problem that is occuring is that if at any point the values are not >> equal it fails the test and ends the testcase. Or if they are all true >> after the first iteration, it will continue to do the loop 100 times.
>> How do I get it to exit the loop as soon as the three conditions are >> equal? While also continuing the loop if they are not equal.
Or like I said in my earlier post, you can do (this is a possibility not a recommendation) *Evaluate* ("${micState}"=="open") and ("${VoiceRecognition}"=="on") and ${DialogActive}
Boolean values in RF are a bit problematic and the core developers have recommended avoiding them when possible. FYI there is a keyword Convert To Boolean in BuiltIn that was probably created for the specific problem of handling True and true and TRUE. Glad you got it working.