hey there, Have a look at this
http://automationwithselenium.blogspot.co.uk/2012/02/how-to-build-request-dynamically-in.html On Thu, Apr 26, 2012 at 8:24 PM, <[email protected]> wrote: > I have a script I have written in a beanshell processor. > > What I need to do is select a random integer (we'll call it X) between 1 > and someVar_matchNr (where someVar is generated by a regex extractor > earlier) > Then select X random matches from someVar. > > The code I have is: > > Integer maxLabels = Integer.parseInt( vars.get > ("otl_Label_List_All_matchNr")); > int numLabelsToRequest = __Random(1, maxLabels)); > > for(int i=1; i<=numLabelsToRequest; i++) { > sampler.addArgument("selectedLabels", vars.get(${__V(otl_Label_List_All_$ > {__Random(1,maxLabels)}_g1)})); > } > > > This code works, as long as I replace all references to "maxLabels" with a > hard coded number. > > Is there a different random number generator I should use, or do I need to > escape the maxLabels somehow? > > As it is written, this code is generating a > java.lang.NumberFormatException, which is telling me that it is trying to > treat maxLabels as a literal string (I think). > > > Any suggestions is greatly appreciated. > > Lee Lowder > > This communication and any attachments are confidential, protected by > Communications Privacy Act 18 USCS ยง 2510, solely for the use of the > intended recipient, and may contain legally privileged material. If you are > not the intended recipient, please return or destroy it immediately. Thank > you. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
