Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
FOR loop in robot framework, how to exit if conditions are met
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Drewcasket  
View profile  
 More options Nov 1 2012, 3:57 pm
From: Drewcasket <drewcasket...@gmail.com>
Date: Thu, 1 Nov 2012 12:57:27 -0700 (PDT)
Local: Thurs, Nov 1 2012 3:57 pm
Subject: FOR loop in robot framework, how to exit if conditions are met

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
GAURAV DEORE  
View profile  
 More options Nov 1 2012, 10:53 pm
From: GAURAV DEORE <gaurav...@gmail.com>
Date: Fri, 2 Nov 2012 08:22:49 +0530
Local: Thurs, Nov 1 2012 10:52 pm
Subject: Re: FOR loop in robot framework, how to exit if conditions are met

Hi,

 You use simple keyword like  "Log    Exit For Loop" exact below the For
keyword aligned.

In ur case like :-

: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
Log   Exit For Loop

---
Regards,
Gaurav

--
*------------------------------*
*Warm Regards,
GAURAV S. DEORE.*

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin O.  
View profile  
 More options Nov 2 2012, 9:11 am
From: "Kevin O." <kormb...@gmail.com>
Date: Fri, 2 Nov 2012 06:11:56 -0700 (PDT)
Local: Fri, Nov 2 2012 9:11 am
Subject: Re: FOR loop in robot framework, how to exit if conditions are met

I would do something like this:

: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.

Kevin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin O.  
View profile  
 More options Nov 2 2012, 9:15 am
From: "Kevin O." <kormb...@gmail.com>
Date: Fri, 2 Nov 2012 06:15:24 -0700 (PDT)
Local: Fri, Nov 2 2012 9:15 am
Subject: Re: FOR loop in robot framework, how to exit if conditions are met

If ${DialogActive} is a true boolean, then you should do
... and ${DialogActive}
  or
... and ("${DialogActive}"=="True")


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin O.  
View profile  
 More options Nov 2 2012, 9:19 am
From: "Kevin O." <kormb...@gmail.com>
Date: Fri, 2 Nov 2012 06:19:31 -0700 (PDT)
Local: Fri, Nov 2 2012 9:19 am
Subject: Re: FOR loop in robot framework, how to exit if conditions are met

Actually I think I like this better:

: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  
      ${signals ok} = | Evaluate | ("${micState}"=="open") and
("${VoiceRecognition}=="on") and ("${DialogActive}"=="true")
      Run Keyword If | ${signals ok} | Exit For Loop
Run Keyword Unless | ${signals ok} | Fail | Conditions not met -
micState:${micState} VoiceRecognition:${VoiceRecognition}
DialogActive:${DialogActive}


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Drewcasket  
View profile  
 More options Nov 2 2012, 9:24 am
From: Drewcasket <drewcasket...@gmail.com>
Date: Fri, 2 Nov 2012 06:24:19 -0700 (PDT)
Local: Fri, Nov 2 2012 9:24 am
Subject: Re: FOR loop in robot framework, how to exit if conditions are met

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Trey Duskin  
View profile  
 More options Nov 2 2012, 12:18 pm
From: Trey Duskin <t...@maldivica.com>
Date: Fri, 2 Nov 2012 09:18:45 -0700 (PDT)
Local: Fri, Nov 2 2012 12:18 pm
Subject: Re: FOR loop in robot framework, how to exit if conditions are met

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Drewcasket  
View profile  
 More options Nov 2 2012, 12:34 pm
From: Drewcasket <drewcasket...@gmail.com>
Date: Fri, 2 Nov 2012 09:34:12 -0700 (PDT)
Local: Fri, Nov 2 2012 12:34 pm
Subject: Re: FOR loop in robot framework, how to exit if conditions are met

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?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Drewcasket  
View profile  
 More options Nov 2 2012, 12:58 pm
From: Drewcasket <drewcasket...@gmail.com>
Date: Fri, 2 Nov 2012 09:58:09 -0700 (PDT)
Local: Fri, Nov 2 2012 12:58 pm
Subject: Re: FOR loop in robot framework, how to exit if conditions are met

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}.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Trey Duskin  
View profile  
 More options Nov 2 2012, 2:40 pm
From: Trey Duskin <t...@maldivica.com>
Date: Fri, 2 Nov 2012 11:40:07 -0700 (PDT)
Local: Fri, Nov 2 2012 2:40 pm
Subject: Re: FOR loop in robot framework, how to exit if conditions are met

I don't think you need to incorporate code, you just need to properly quote
the RF variables in your Evaluate keyword call.  E.g:

*Evaluate* ("${micState}"=="open") and ("${VoiceRecognition}"=="on") and
"${DialogActive}"=="true"

That way python will just compare the strings.  The quotes do not escape RF
variables.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin O.  
View profile  
 More options Nov 2 2012, 3:29 pm
From: "Kevin O." <kormb...@gmail.com>
Date: Fri, 2 Nov 2012 12:29:53 -0700 (PDT)
Local: Fri, Nov 2 2012 3:29 pm
Subject: Re: FOR loop in robot framework, how to exit if conditions are met

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.

Kevin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »