You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Rajiv Nanduani <ra...@gmail.com> on 2011/01/26 16:36:24 UTC

actual usage of Bean shell scripting in jmeter with example

Hi All,

I have gone through the bean shell scripting in jmeter but i did not find
any example of that, how it is useful in jmeter and which way.means reading
the sampler values etc.
Can any one explain  bean shell scripting in Jmeter with example.In
beanshell post/pre processor script where we write the script.
I am struggling with this what is the actual usage of it .Please explain
with this .it would be great help for me or others as well for understanding
the usage of it.

-- 
RAJIV KUMAR

<http://rajivkumarnandvani.wordpress.com/>
<http://learnqtphelp.blogspot.com/>

Re: actual usage of Bean shell scripting in jmeter with example

Posted by Rajiv Nanduani <ra...@gmail.com>.
I did the same on same version as u mentioned.
are you writing some import statements in bean shell script area?
like this
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.assertions.AssertionResult;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.JMeterVariables;

On Fri, Jan 28, 2011 at 1:03 AM, Garvita <ga...@tcs.com> wrote:

>
> In the end try printing something like this,
> print("ok")
>  it should go to file and check your extracted variable value.
> I did this in Jakarta-Jmeter 2.3.4, in which version you are trying???
>
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/actual-usage-of-Bean-shell-scripting-in-jmeter-with-example-tp3358087p3360938.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>


-- 
RAJIV KUMAR

<http://rajivkumarnandvani.wordpress.com/>
<http://learnqtphelp.blogspot.com/>

Re: actual usage of Bean shell scripting in jmeter with example

Posted by Garvita <ga...@tcs.com>.
In the end try printing something like this,
print("ok")
 it should go to file and check your extracted variable value.
I did this in Jakarta-Jmeter 2.3.4, in which version you are trying???

-- 
View this message in context: http://jmeter.512774.n5.nabble.com/actual-usage-of-Bean-shell-scripting-in-jmeter-with-example-tp3358087p3360938.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: actual usage of Bean shell scripting in jmeter with example

Posted by Rajiv Nanduani <ra...@gmail.com>.
k but still it is not working. can you send me your testscript fle( jmx). +
jmeter .properties file

On Fri, Jan 28, 2011 at 4:10 AM, Garvita <ga...@tcs.com> wrote:

>
> Import statement is not required...........
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/actual-usage-of-Bean-shell-scripting-in-jmeter-with-example-tp3358087p3361134.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>


-- 
RAJIV KUMAR

<http://rajivkumarnandvani.wordpress.com/>
<http://learnqtphelp.blogspot.com/>

Re: actual usage of Bean shell scripting in jmeter with example

Posted by Garvita <ga...@tcs.com>.
Import statement is not required...........
-- 
View this message in context: http://jmeter.512774.n5.nabble.com/actual-usage-of-Bean-shell-scripting-in-jmeter-with-example-tp3358087p3361134.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: actual usage of Bean shell scripting in jmeter with example

Posted by Deepak Shetty <sh...@gmail.com>.
When any of the out of box stuff doesnt do what you want , this is an easy
way to extend JMeter by writing some java code. You need to know some Java
and you need to lookup the JMeter javadocs to figure out how to interact
with Jmeter classes.
search the mail archives. for practical examples.
http://theworkaholic.blogspot.com/2010/03/dynamic-parameters-in-jmeter.html

On Wed, Jan 26, 2011 at 7:36 AM, Rajiv Nanduani <
rajivkumarnandvani@gmail.com> wrote:

> Hi All,
>
> I have gone through the bean shell scripting in jmeter but i did not find
> any example of that, how it is useful in jmeter and which way.means reading
> the sampler values etc.
> Can any one explain  bean shell scripting in Jmeter with example.In
> beanshell post/pre processor script where we write the script.
> I am struggling with this what is the actual usage of it .Please explain
> with this .it would be great help for me or others as well for
> understanding
> the usage of it.
>
> --
> RAJIV KUMAR
>
> <http://rajivkumarnandvani.wordpress.com/>
> <http://learnqtphelp.blogspot.com/>
>

Re: actual usage of Bean shell scripting in jmeter with example

Posted by Garvita <ga...@tcs.com>.
I have used Beanshell Post Processor to store dynamically generated values in
a text file. 
Here in this case I have extracted the "REFID" value using Regular
Expression Extractor and these value is stored in ids.txt placed at
C:\\Report folder as:

output = vars.get("REFID");

log.info(output); 


f = new FileOutputStream("C:\\Report\\id.txt");

p = new PrintStream(f);

this.interpreter.setOut(p);

print(output);



-- 
View this message in context: http://jmeter.512774.n5.nabble.com/actual-usage-of-Bean-shell-scripting-in-jmeter-with-example-tp3358087p3359633.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org