>From my observations it looks like if a parameter is set to a variable in
BeanShell PostProcessor i.e. ${__setProperty(parameterName,variableName)},
printing the parameterName value to console i.e.
print(${__P(parameterName)}) works as expected (if variableName was declared
in BeanShell as: String variableName = “mary had a little lamb”, it would
print “mary had a little lamb”).

However, in BeanShell PostProcessor in a separate ThreadGroup
print(${__P(parameterName)}) causes an error because variableName doesn’t
exist (not in scope I guess).

Setting parameterName to a literal eg. “quick brown fox” prints as expected
in both ThreadGroups.

I’ve come to the conclusion that ${__P(parameterName)} evaluates to the
variable variableName (parameterName is a pointer to the variable perhaps?)
and works in the initial ThreadGroup as variableName is within scope
containing value “mary had a little lamb” but doesn’t work in the second
ThreadGroup as variableName is out now out of scope.


In a nutshell this is what I think is happening ("a <- b" means a request
value from b):


Initial ThreadGroup:
${__P(parameterName)}  <- variableName <-  “mary had a little lamb”

Second ThreadGroup:
${__P(parameterName)}  <- variableName <-  !!Error, variableName doesn’t
exist here!!


This has really got me snookered passing values between ThreadGroups; I
don’t have an initialisation file so it must be my code which is incorrect:

ThreadGroup1’s
${__setProperty(securityid,bsh.args[0],true)};

Or 

ThreadGroup2’s
${__P(securityid)};


Thanks guys,
Mark




sebb-2-2 wrote:
> 
> On 29/09/2008, Mark24 <[EMAIL PROTECTED]> wrote:
>>
>>  Thanks Sebb. I've tried your suggestions but had hit another snag:
>>
>>  I call Jmeter at the command window by "Jmeter -Jsecurityid=123" to
>> create a
>>  parameter securityid with default value "123".
>>
>>
>>  + Test Plan
>>  ++ Thread Group1
>>  +++ WebService(SOAP) Request1
>>  ++++ XPath Extractor
>>  ++++ BeanShell PostProcessor1
>>
>>  ++ Thread Group2
>>  +++ WebService(SOAP) Request2
>>  ++++ BeanShell PostProcessor2
>>
>>
>>  In Thread Group1, XPath Extractor I set:
>>  - Reference Name = theSID
>>  - Xpath query = //sid
>>  - Default Value = "nomatchfound"
>>
>>  In Thread Group1, BeanShell PostProcessor1 I set:
>>  - Reset Interpreter = False
>>  - Parameters = ${theSID}
>>  - Script = ${__setProperty(securityid,bsh.args[0],true)};
>>  print(${__P(securityid)});
>>
>>
>>  In Thread Group2, BeanShell PostProcessor2 I set:
>>  - Reset Interpreter = False
>>  - Parameters =
>>  - Script = print(${__P(securityid)});
>>
>>
>>  I run this Test Plan, it extracts //sid (say, "123456", sets securityid
>> to
>>  "123456" and prints to console "123456" in BeanShell PostProcessor1, but
>> in
>>  Thread Group2's BeanShell PostProcessor2 it doesn't print to console but
>>  instead logs an error in jmeter.log mentioning "Error invoking bsh
>> method:
>>  eval Sourced file: inline evaluation of: ''print(bsh.args[0]);''"
>>
>>
>>  I expect print(${__P(securityid)}); in BeanShell PostProcessor2 to print
>>  "123456" but is looks like it is evaluating bsh.args[0] and because it
>>  doesn't exist here it errors out.
>>
>>  What am i doing wrong?
> 
> Neither JMeter nor BeanShell will add ''print(bsh.args[0]);'' to the
> script by themselves, so there must be an error in your BeanShell
> script - or perhaps initialisation file.
> 
>>
>>
>>
>>
>>  sebb-2-2 wrote:
>>  >
>>  > On 26/09/2008, Mark24 <[EMAIL PROTECTED]> wrote:
>>  >>
>>  >>  Thanks for your reply sebb, you are very informative (i've been
>> reading
>>  >> your
>>  >>  answer to questions quite often over the last 3 days ive been using
>>  >> JMeter).
>>  >>
>>  >>  My grand plan is to regression test my company's MS web services by
>>  >> loging
>>  >>  in once to get the security id, then spawn multiple virtual users to
>>  >> work
>>  >>  together to call the other WS methods using a collection of inputs
>> from
>>  >> a
>>  >>  database. certain values from the responses are planned to be
>> inserted
>>  >> into
>>  >>  a database to later run some sql to compare these values against a
>> test
>>  >>  baseline database.
>>  >>
>>  >>  I was using one thread group which was spawning a single user to to
>> get
>>  >> the
>>  >>  security id, then the second thread group would spawn n virtual
>> users.
>>  >>
>>  >
>>  > OK, it was not clear that you wanted to use a single id in multiple
>>  > threads.
>>  >
>>  > In which case, use two thread groups, and set them to run one after
>>  > another.
>>  >
>>  > Extract the id you want to use, and save it as a JMeter Property using
>>  > the function:
>>  >
>>  >
>> http://jakarta.apache.org/jmeter/usermanual/functions.html#__setProperty
>>  >
>>  > You can then use the __P() function to retrieve the value in the
>>  > second thread group.
>>  >
>>  > Or if you already have a lot of samplers using a variable, just add a
>>  > user parameters pre-processor to the first one and copy the property
>>  > to the variable there.
>>  >
>>  >>  I'm possibly approaching the solution to my problem incorrectly so
>>  >> please
>>  >>  comment or point me to some reading material. My Jmeter textbook has
>>  >> been
>>  >>  order on Amazon but until then, the jmeter docs and forums like this
>> are
>>  >> my
>>  >>  friends.
>>  >
>>  > There's also quite a lot of information on the Wiki.
>>  >
>>  >>  Thanks again Sebb,
>>  >>
>>  >>  Mark
>>  >>
>>  >>
>>  >>  sebb-2-2 wrote:
>>  >>  >
>>  >>  > On 26/09/2008, Mark24 <[EMAIL PROTECTED]> wrote:
>>  >>  >>
>>  >>  >>  In Jmeter 2.3.2, how do I pass a value obtained in "Thread Group
>> 1"
>>  >>  >> (with
>>  >>  >>  "XPath Extractor" from a "WebService(SOAP) Request") to "Thread
>>  >> Group 2"
>>  >>  >> for
>>  >>  >>  use as input to "WebService(SOAP) Request"
>>  >>  >>
>>  >>  >>  Graphically:
>>  >>  >>
>>  >>  >>  "Thread Group 1"
>>  >>  >>    "WebService(SOAP) Request"  //login() WS method which returns
>> a
>>  >>  >> security
>>  >>  >>  ID
>>  >>  >>    "XPath Extractor"  //extract security ID to security_ID
>> variable
>>  >>  >>  "Thread Group 2"
>>  >>  >>    "WebService(SOAP) Request"  //use ${security_ID} as a
>> parameter to
>>  >>  >> this
>>  >>  >>  Search() WS method
>>  >>  >>
>>  >>  >>
>>  >>  >>  Variable security_ID declared in "Thread Group 1"'s "XPath
>>  >> Extractor"
>>  >>  >> seems
>>  >>  >>  to be very narrowly scoped as "${security_ID}" is literally used
>> as
>>  >>  >> input to
>>  >>  >>  "Thread Group 2"'s "WebService(SOAP) Request" instead of the
>> value
>>  >> of
>>  >>  >>  ${security_ID}.
>>  >>  >>
>>  >>  >>  I've tried declaring the security_ID variable in "Test Plan to
>> use"
>>  >> but
>>  >>  >> this
>>  >>  >>  doesn't work (${security_ID} resolves to the value i set during
>>  >>  >> declaration
>>  >>  >>  instead of the extracted value).
>>  >>  >
>>  >>  > Why not use the same Thread Group for the two SOAP requests?
>>  >>  >
>>  >>  > e.g.
>>  >>  >
>>  >>  > Thread Group
>>  >>  > + SOAP
>>  >>  > + + XPath
>>  >>  > + SOAP using variable
>>  >>  >
>>  >>  > If you want to run multiple requests with the same variable, just
>> add
>>  >>  > them at the end, or enclose in a loop:
>>  >>  >
>>  >>  > Thread Group
>>  >>  > + SOAP
>>  >>  > + + XPath
>>  >>  > + Loop
>>  >>  > + + SOAP using variable
>>  >>  >
>>  >>  >>  Thanks for any help,
>>  >>  >>  Mark
>>  >>  >>
>>  >>  >>
>>  >>  >>  --
>>  >>  >>  View this message in context:
>>  >>  >>
>>  >>
>> http://www.nabble.com/how-do-I-pass-a-value-obtained-in-%22Thread-Group-1%22-%28with-%22XPath-Extractor%22-from-a-%22WebService%28SOAP%29-Request%22%29-to-%22Thread-Group-2%22-for-use-as-input-to-%22WebService%28SOAP%29-Request%22-tp19683794p19683794.html
>>  >>  >>  Sent from the JMeter - User mailing list archive at Nabble.com.
>>  >>  >>
>>  >>  >>
>>  >>  >>
>>  >> ---------------------------------------------------------------------
>>  >>  >>  To unsubscribe, e-mail:
>> [EMAIL PROTECTED]
>>  >>  >>  For additional commands, e-mail:
>> [EMAIL PROTECTED]
>>  >>  >>
>>  >>  >>
>>  >>  >
>>  >>  >
>> ---------------------------------------------------------------------
>>  >>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  >>  > For additional commands, e-mail:
>> [EMAIL PROTECTED]
>>  >>  >
>>  >>  >
>>  >>  >
>>  >>
>>  >>
>>  >> --
>>  >>  View this message in context:
>>  >>
>> http://www.nabble.com/how-do-I-pass-a-value-obtained-in-%22Thread-Group-1%22-%28with-%22XPath-Extractor%22-from-a-%22WebService%28SOAP%29-Request%22%29-to-%22Thread-Group-2%22-for-use-as-input-to-%22WebService%28SOAP%29-Request%22-tp19683794p19686226.html
>>  >>
>>  >> Sent from the JMeter - User mailing list archive at Nabble.com.
>>  >>
>>  >>
>>  >> 
>> ---------------------------------------------------------------------
>>  >>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  >>  For additional commands, e-mail: [EMAIL PROTECTED]
>>  >>
>>  >>
>>  >
>>  > ---------------------------------------------------------------------
>>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  > For additional commands, e-mail: [EMAIL PROTECTED]
>>  >
>>  >
>>  >
>>
>>  --
>>
>> View this message in context:
>> http://www.nabble.com/how-do-I-pass-a-value-obtained-in-%22Thread-Group-1%22-%28with-%22XPath-Extractor%22-from-a-%22WebService%28SOAP%29-Request%22%29-to-%22Thread-Group-2%22-for-use-as-input-to-%22WebService%28SOAP%29-Request%22-tp19683794p19718151.html
>>
>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/how-do-I-pass-a-value-obtained-in-%22Thread-Group-1%22-%28with-%22XPath-Extractor%22-from-a-%22WebService%28SOAP%29-Request%22%29-to-%22Thread-Group-2%22-for-use-as-input-to-%22WebService%28SOAP%29-Request%22-tp19683794p19753696.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to