Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use JMeter Property props.get props.put from WebDriver Sampler (JMeter)

Tags:

I create some features/functions from first Thread Group and put them into a JMeter Property:

props.put("FUNCTIONS", new function());

Then I would like to call those features/functions in WebDriver Sampler of the other Thread Groups.

In normal way (BSF, Beanshell or JSR223), just using:

props.get("FUNCTIONS")

But how to do this in WebDriver Sampler?

There is the same question related to vars here :

  • How to pass variable in Webdriver-Sampler | Jmeter Webdriver
  • How to set JMeter Vars from within WebDriver Sampler?

Could anyone please help me?

Thanks in advance.

like image 518
Tom Tran Avatar asked Jul 04 '16 12:07

Tom Tran


People also ask

What does the __ property function return in JMeter?

Per the JMeter user guide __property(): The property function returns the value of a JMeter property. If the property value cannot be found, and no default has been supplied, it returns the property name.

What is Webdriver sampler in JMeter?

JMeter Web Driver Sampler is used to measure end user experience of the system under test while it receives load from traditional JMeter samplers such as HTTP or JDBC Samplers.

What is __ P in JMeter?

Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function. When using \ before a variable for a windows path for example C:\test\${test}, ensure you escape the \ otherwise JMeter will not interpret the variable, example: C:\\test\\${test}.

What is CTX in JMeter?

ctx is the most powerful variable exposed to BeanShell. It represents the org. apache. jmeter. threads.


1 Answers

A little bit weird to hear such a question from someone who is familiar with Beanshell, however here you go:

Something like:

var props = org.apache.jmeter.util.JMeterUtils.getJMeterProperties()

will provide you read/write access to JMeter Properties.

References:

  • JMeterUtils.getJMeterProperties()
  • Using Java From Scripts
  • The WebDriver Sampler: Your Top 10 Questions Answered
like image 136
Dmitri T Avatar answered Sep 28 '22 04:09

Dmitri T