Create multiple Transaction Controllers in single JSR 223 Sampler script.. ?

40 views
Skip to first unread message

Avinash Kumar

unread,
Apr 2, 2024, 2:19:06 PMApr 2
to jmeter-plugins
Hi there,

I am running a single JSR223 Sampler script using Groovy.
It does following actions after creating a new "ChromeDriver" object.

01. Visit Facebook.
02. Enter Id/pass
03. Press Submit
04. Click Marketplace

How can I wrap above four steps in 4 separate transaction controller so that when I run the test; even though 1 single JSR223 script is running, it will show me 4 separate transaction controller + the time taken for each step listed above ? 

Dmitri T

unread,
Apr 2, 2024, 2:33:18 PMApr 2
to jmeter-plugins
Your question is not related to JMeter Plugins project, you should ask questions like this i.e. in JMeter Forum

With regards to question itself: you cannot create 4 transaction controllers out of 1 JSR223 Sampler, the options are in:

  1. Pass ChromeDriver instance between samplers using JMeterVariables class instance like:
    • in first Sampler in the end do vars.putObject('driver', your-chromedriver-instance)
    • in second Sampler in the beginning do def your-chromedriver-instance = vars.getObject('driver')
    • etc
  2. Create a sub-result for each logical action via SampleResult.addSubResult() function , something like:
     def visitFacebook = new org.apache.jmeter.samplers.SampleResult()
     visitFacebook.sampleStart()
     //do what you need nere
     visitFacebook.setSuccessful(true)
     visitFacebook.sampleEnd()
     SampleResult.addSubResult(visitFacebook)

     def enterIdPass = new org.apache.jmeter.samplers.SampleResult()
     enterIdPass.sampleStart()
     //do what you need nere
     enterIdPass.setSuccessful(true)
     enterIdPass.sampleEnd()
     SampleResult.addSubResult(enterIdPass)

More information on these and other JMeter API shorthands: Top 8 JMeter Java Classes You Should Be Using with Groovy

Avinash Kumar

unread,
Apr 2, 2024, 2:53:24 PMApr 2
to jmeter-plugins
Thank you !! 
You are the best !!!!!!!!!!!!!!!!!
Reply all
Reply to author
Forward
0 new messages