mirror of https://github.com/apache/jmeter.git
				
				
				
			
		
			
				
	
	
		
			4231 lines
		
	
	
		
			92 KiB
		
	
	
	
		
			HTML
		
	
	
	
			
		
		
	
	
			4231 lines
		
	
	
		
			92 KiB
		
	
	
	
		
			HTML
		
	
	
	
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 | |
| <!--
 | |
|    Licensed to the Apache Software Foundation (ASF) under one or more
 | |
|    contributor license agreements.  See the NOTICE file distributed with
 | |
|    this work for additional information regarding copyright ownership.
 | |
|    The ASF licenses this file to You under the Apache License, Version 2.0
 | |
|    (the "License"); you may not use this file except in compliance with
 | |
|    the License.  You may obtain a copy of the License at
 | |
|  
 | |
|        http://www.apache.org/licenses/LICENSE-2.0
 | |
|  
 | |
|    Unless required by applicable law or agreed to in writing, software
 | |
|    distributed under the License is distributed on an "AS IS" BASIS,
 | |
|    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|    See the License for the specific language governing permissions and
 | |
|    limitations under the License.
 | |
| -->
 | |
| 
 | |
| <!-- Content Stylesheet for Site -->
 | |
| 
 | |
| 
 | |
| <!-- start the processing -->
 | |
| <!-- ====================================================================== -->
 | |
| <!-- Main Page Section -->
 | |
| <!-- ====================================================================== -->
 | |
| <html>
 | |
| <head>
 | |
| <link rel="stylesheet" type="text/css" href="../css/style.css"/>
 | |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
 | |
| 
 | |
| 
 | |
| 
 | |
| <title>Apache JMeter - User's Manual: Functions and Variables</title>
 | |
| </head>
 | |
| 
 | |
| <body bgcolor="#ffffff" text="#000000" link="#525D76">
 | |
| <table border="0" cellspacing="0">
 | |
| <!-- TOP IMAGE -->
 | |
| <tr>
 | |
| <td>
 | |
| <!-- Need to specify height otherwise iframe seems to grab extra -->
 | |
| <iframe src="http://www.apache.org/ads/halfbanner.html" height="102"
 | |
| style="border-width:0; float: left" frameborder="0" scrolling="no"></iframe>
 | |
| </td>
 | |
| <td align="left">
 | |
| <a href="http://www.apache.org"><img title="Apache Software Foundation" width="387" height="100" src="../images/asf-logo.gif" border="0"/></a>
 | |
| </td>
 | |
| <td align="right">
 | |
| <a href="http://jmeter.apache.org/"><img width="221" height="102" src="../images/logo.jpg" alt="Apache JMeter" title="Apache JMeter" border="0"/></a>
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| <table border="0" width="100%" cellspacing="4">
 | |
| <tr><td colspan="2">
 | |
| <hr noshade size="1"/>
 | |
| </td></tr>
 | |
| <tr>
 | |
| <!-- LEFT SIDE NAVIGATION -->
 | |
| <td width="20%" valign="top" nowrap="true">
 | |
| <p><strong>About</strong></p>
 | |
| <ul>
 | |
| <li><a href="../index.html">Overview</a>
 | |
| </li>
 | |
| <li><a href="../changes.html">Changes</a>
 | |
| </li>
 | |
| <li><a href="http://projects.apache.org/feeds/rss/jmeter.xml">Subscribe to What's New</a>
 | |
| </li>
 | |
| <li><a href="../issues.html">Issues</a>
 | |
| </li>
 | |
| <li><a href="http://www.apache.org/licenses/">License</a>
 | |
| </li>
 | |
| <li><a href="http://wiki.apache.org/jmeter/JMeterCommitters">Contributors</a>
 | |
| </li>
 | |
| </ul>
 | |
| <p><strong>Download</strong></p>
 | |
| <ul>
 | |
| <li><a href="../download_jmeter.cgi">Download Releases</a>
 | |
| </li>
 | |
| <li><a href="../nightly.html">Developer (Nightly) Builds</a>
 | |
| </li>
 | |
| </ul>
 | |
| <p><strong>Documentation</strong></p>
 | |
| <ul>
 | |
| <li><a href="../usermanual/index.html">User Manual</a>
 | |
| </li>
 | |
| <li><a href="../usermanual/component_reference.html">Component Reference</a>
 | |
| </li>
 | |
| <li><a href="../usermanual/functions.html">Functions Reference</a>
 | |
| </li>
 | |
| <li><a href="../api/index.html">Javadocs</a>
 | |
| </li>
 | |
| <li><a href="../localising/index.html">Localisation (Translator's Guide)</a>
 | |
| </li>
 | |
| <li><a href="../building.html">Building JMeter and Add-Ons</a>
 | |
| </li>
 | |
| <li><a href="http://wiki.apache.org/jmeter">JMeter Wiki</a>
 | |
| </li>
 | |
| <li><a href="http://wiki.apache.org/jmeter/JMeterFAQ">FAQ (Wiki)</a>
 | |
| </li>
 | |
| </ul>
 | |
| <p><strong>Tutorials (PDF format)</strong></p>
 | |
| <ul>
 | |
| <li><a href="../usermanual/jmeter_distributed_testing_step_by_step.pdf">Distributed Testing</a>
 | |
| </li>
 | |
| <li><a href="../usermanual/jmeter_proxy_step_by_step.pdf">Recording Tests</a>
 | |
| </li>
 | |
| <li><a href="../usermanual/junitsampler_tutorial.pdf">JUnit Sampler</a>
 | |
| </li>
 | |
| <li><a href="../usermanual/jmeter_accesslog_sampler_step_by_step.pdf">Access Log Sampler</a>
 | |
| </li>
 | |
| <li><a href="../extending/jmeter_tutorial.pdf">Extending JMeter</a>
 | |
| </li>
 | |
| </ul>
 | |
| <p><strong>Community</strong></p>
 | |
| <ul>
 | |
| <li><a href="http://www.apache.org/foundation/getinvolved.html">Get Involved</a>
 | |
| </li>
 | |
| <li><a href="../mail.html">Mailing Lists</a>
 | |
| </li>
 | |
| <li><a href="../svnindex.html">SVN Repositories</a>
 | |
| </li>
 | |
| </ul>
 | |
| <p><strong>Foundation</strong></p>
 | |
| <ul>
 | |
| <li><a href="http://www.apache.org/">ASF</a>
 | |
| </li>
 | |
| <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a>
 | |
| </li>
 | |
| <li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a>
 | |
| </li>
 | |
| </ul>
 | |
| </td>
 | |
| <td width="80%" align="left" valign="top">
 | |
| <table>
 | |
| <tr>
 | |
| <td bgcolor="#525D76">
 | |
| <div align="right"><a href="index.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Index</font></a></div>
 | |
| </td>
 | |
| <td bgcolor="#525D76">
 | |
| <div align="right"><a href="regular_expressions.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Next</font></a></div>
 | |
| </td>
 | |
| <td bgcolor="#525D76">
 | |
| <div align="right"><a href="component_reference.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Prev</font></a></div>
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| <br>
 | |
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
 | |
| <tr><td bgcolor="#525D76">
 | |
| <font color="#ffffff" face="arial,helvetica,sanserif">
 | |
| <a name="functions"><strong>19. Functions and Variables</strong></a><a class="sectionlink" href="#functions" title="Link to here">¶</a></font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <blockquote>
 | |
| <p>
 | |
| 
 | |
| JMeter functions are special values that can populate fields of any Sampler or other
 | |
| element in a test tree.  A function call looks like this:
 | |
| </p>
 | |
| <p>
 | |
| <code>
 | |
| ${__functionName(var1,var2,var3)}
 | |
| </code>
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| Where "__functionName" matches the name of a function.
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| Parentheses surround the parameters sent to the function, for example ${__time(YMD)}
 | |
| The actual parameters vary from function to function.  
 | |
| Functions that require no parameters can leave off the parentheses, for example ${__threadNum}.
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| If a function parameter contains a comma, then be sure to escape this with "\", otherwise JMeter will treat it as a parameter delimiter.
 | |
| For example:
 | |
| 
 | |
| <pre>
 | |
| 
 | |
| ${__time(EEE\, d MMM yyyy)}
 | |
| 
 | |
| </pre>
 | |
| 
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| Variables are referenced as follows:
 | |
| 
 | |
| <pre>
 | |
| 
 | |
| ${VARIABLE}
 | |
| 
 | |
| </pre>
 | |
| 
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| 
 | |
| <b>
 | |
| 
 | |
| If an undefined function or variable is referenced, JMeter does not report/log an error - the reference is returned unchanged.
 | |
| For example if UNDEF is not defined as a variable, then the value of ${UNDEF} is ${UNDEF}.
 | |
| 
 | |
| </b>
 | |
| 
 | |
| Variables, functions (and properties) are all case-sensitive.
 | |
| 
 | |
| <b>
 | |
| 
 | |
| Versions of JMeter after 2.3.1 trim spaces from variable names before use, so for example
 | |
| ${__Random(1,63, LOTTERY )} will use the variable 'LOTTERY' rather than ' LOTTERY '.
 | |
| 
 | |
| </b>
 | |
| 
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| Properties are not the same as variables.
 | |
| Variables are local to a thread; properties are common to all threads,
 | |
| and need to be referenced using the __P or __property function.
 | |
| 
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| List of functions, loosely grouped into types.
 | |
| </p>
 | |
| <table>
 | |
| <tr>
 | |
| <td bgcolor="#039acc"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Type of function
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#039acc"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Name
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#039acc"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Comment
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#039acc"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Since
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Information
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__threadNum">threadNum</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| get thread number
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 1.X
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Information
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__samplerName">samplerName</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| get the sampler name (label)
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.5
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Information
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__machineIP">machineIP</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| get the local machine IP address
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.6
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Information
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__machineName">machineName</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| get the local machine name
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 1.X
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Information
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__time">time</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| return current time in various formats
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.2
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Information
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__log">log</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| log (or display) a message (and return the value)
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.2
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Information
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__logn">logn</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| log (or display) a message (empty return value)
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.2
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Input
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__StringFromFile">StringFromFile</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| read a line from a file
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 1.9
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Input
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__FileToString">FileToString</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| read an entire file
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.4
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Input
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__CSVRead">CSVRead</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| read from CSV delimited file
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 1.9
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Input
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__XPath">XPath</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Use an XPath expression to read from a file
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.0.3
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Calculation
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__counter">counter</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| generate an incrementing number
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 1.X
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Calculation
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__intSum">intSum</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| add int numbers
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 1.8.1
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Calculation
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__longSum">longSum</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| add long numbers
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.3.2
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Calculation
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__Random">Random</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| generate a random number
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 1.9
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Calculation
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__RandomString">RandomString</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| generate a random string
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.6
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Scripting
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__BeanShell">BeanShell</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| run a BeanShell script
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 1.X
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Scripting
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__javaScript">javaScript</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| process JavaScript (Mozilla Rhino)
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 1.9
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Scripting
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__jexl">jexl, jexl2</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| evaluate a Commons Jexl expression
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| jexl(2.2), jexl2(2.6)
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Properties
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__property">property</a> 
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| read a property
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.0
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Properties
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__P">P</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| read a property (shorthand method)
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.0
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Properties
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__setProperty">setProperty</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| set a JMeter property
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.1
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Variables
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__split">split</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Split a string into variables
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.0.2
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Variables
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__V">V</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| evaluate a variable name
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.3RC3
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Variables
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__eval">eval</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| evaluate a variable expression
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.3.1
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Variables
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__evalVar">evalVar</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| evaluate an expression stored in a variable
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.3.1
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| String
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__regexFunction">regexFunction</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| parse previous response using a regular expression
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 1.X
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| String
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__char">char</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| generate Unicode char values from a list of numbers
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.3.3
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| String
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__unescape">unescape</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Process strings containing Java escapes (e.g. \n & \t)
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.3.3
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| String
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__unescapeHtml">unescapeHtml</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Decode HTML-encoded strings
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.3.3
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| String
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__escapeHtml">escapeHtml</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Encode strings using HTML encoding
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.3.3
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| String
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
|  <a href="#__TestPlanName">TestPlanName</a>
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| Return name of current test plan
 | |
| </font>
 | |
| </td>
 | |
| <td bgcolor="#a0ddf0"   valign="top" align="left">
 | |
| <font color="#000000" size="-1" face="arial,helvetica,sanserif">
 | |
| 2.6
 | |
| </font>
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| <p>
 | |
| </p>
 | |
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
 | |
| <tr><td bgcolor="#828DA6">
 | |
| <font color="#ffffff" face="arial,helvetica,sanserif">
 | |
| <a name="what_can_do"><strong>19.1 What can functions do</strong></a>
 | |
| <a class="sectionlink" href="#what_can_do" title="Link to here">¶</a></font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <blockquote>
 | |
| <p>
 | |
| There are two kinds of functions: user-defined static values (or variables), and built-in functions.
 | |
| <br>
 | |
| 
 | |
| 
 | |
| User-defined static values allow the user to define variables to be replaced with their static value when
 | |
| a test tree is compiled and submitted to be run.  This replacement happens once at the beginning of the test
 | |
| run.  This could be used to replace the DOMAIN field of all HTTP requests, for example - making it a simple 
 | |
| matter to change a test to target a different server with the same test.
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| Note that variables cannot currently be nested; i.e ${Var${N}} does not work.
 | |
| The __V (variable) function (versions after 2.2) can be used to do this: ${__V(Var${N})}.
 | |
| In earlier JMeter versions one can use ${__BeanShell(vars.get("Var${N}")}.
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| This type of replacement is possible without functions, but was less convenient and less intuitive.
 | |
| It required users to create default config elements that would fill in blank values of Samplers.
 | |
| Variables allow one to replace only part of any given value, not just filling in blank values.
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| With built-in functions users can compute new values at run-time based on previous response data, which
 | |
| thread the function is in, the time, and many other sources.  These values are generated fresh for every
 | |
| request throughout the course of the test. 
 | |
| </p>
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>Functions are shared between threads. 
 | |
| Each occurrence of a function call in a test plan is handled by a separate function instance.
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| </blockquote>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
 | |
| <tr><td bgcolor="#828DA6">
 | |
| <font color="#ffffff" face="arial,helvetica,sanserif">
 | |
| <a name="where"><strong>19.2 Where can functions and variables be used?</strong></a>
 | |
| <a class="sectionlink" href="#where" title="Link to here">¶</a></font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <blockquote>
 | |
| <p>
 | |
| 
 | |
| Functions and variables can be written into any field of any test component (apart from the TestPlan - see below).
 | |
| Some fields do not allow random strings 
 | |
| because they are expecting numbers, and thus will not accept a function.  However, most fields will allow
 | |
| functions.
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| Functions which are used on the Test Plan have some restrictions.
 | |
| JMeter thread variables will have not been fully set up when the functions are processed, 
 | |
| so variable names passed as parameters will not be set up, and variable references will not work, 
 | |
| so split() and regex() and the variable evaluation functions won't work. 
 | |
| The threadNum() function won't work (and does not make sense at test plan level).
 | |
| The following functions should work OK on the test plan:
 | |
| 
 | |
| <ul>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| intSum
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| longSum
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| machineName
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| BeanShell
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| javaScript
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| jexl
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| random
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| time
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| property functions
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| log functions
 | |
| </li>
 | |
| 
 | |
| 
 | |
| </ul>
 | |
| 
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| Configuration elements are processed by a separate thread.
 | |
| Therefore functions such as __threadNum do not work properly in elements such as User Defined Variables.
 | |
| Also note that variables defined in a UDV element are not available until the element has been processed.
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>When using variable/function references in SQL code (etc),
 | |
| remember to include any necessary quotes for text strings,
 | |
| i.e. use
 | |
| <br>
 | |
| 
 | |
| 
 | |
| SELECT item from table where name='${VAR}'
 | |
| 
 | |
| <br>
 | |
| 
 | |
| <b>
 | |
| not
 | |
| </b>
 | |
| 
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| SELECT item from table where name=${VAR}
 | |
| 
 | |
| <br>
 | |
| 
 | |
| (unless VAR itself contains the quotes)
 | |
| 
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| </blockquote>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
 | |
| <tr><td bgcolor="#828DA6">
 | |
| <font color="#ffffff" face="arial,helvetica,sanserif">
 | |
| <a name="how"><strong>19.3 How to reference variables and functions</strong></a>
 | |
| <a class="sectionlink" href="#how" title="Link to here">¶</a></font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <blockquote>
 | |
| <p>
 | |
| Referencing a variable in a test element is done by bracketing the variable name with '${' and '}'.
 | |
| </p>
 | |
| <p>
 | |
| Functions are referenced in the same manner, but by convention, the names of
 | |
| functions begin with "__" to avoid conflict with user value names
 | |
| <sup>
 | |
| *
 | |
| </sup>
 | |
| .  Some functions take arguments to
 | |
| configure them, and these go in parentheses, comma-delimited.  If the function takes no arguments, the parentheses can
 | |
| be omitted.
 | |
| </p>
 | |
| <p>
 | |
| <b>
 | |
| Argument values that themselves contain commas should be escaped as necessary.
 | |
| If you need to include a comma in your parameter value, escape it like so: '\,'.
 | |
| </b>
 | |
| 
 | |
| This applies for example to the scripting functions - Javascript, Beanshell, Jexl - where it is necessary to escape any commas
 | |
| that may be needed in script method calls - e.g.
 | |
| 
 | |
| </p>
 | |
| <pre>
 | |
| 
 | |
|     ${__BeanShell(vars.put("name"\,"value"))}
 | |
| 
 | |
| </pre>
 | |
| <p>
 | |
| 
 | |
| Alternatively, you can define your script as a variable, e.g. on the Test Plan:
 | |
| 
 | |
| <pre>
 | |
| SCRIPT          vars.put("name","value")
 | |
| </pre>
 | |
| 
 | |
| The script can then be referenced as follows:
 | |
| 
 | |
| <pre>
 | |
| ${__BeanShell(${SCRIPT})}
 | |
| </pre>
 | |
| 
 | |
| There is no need to escape commas in the SCRIPT variable because the function call is parsed before the variable is replaced with its value.
 | |
| This works well in conjunction with the BSF or BeanShell Samplers, as these can be used to test Javascript, Jexl and BeanShell scripts.
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| Functions can reference variables and other functions, for example 
 | |
| 
 | |
| <code>
 | |
| ${__XPath(${__P(xpath.file),${XPATH})}
 | |
| </code>
 | |
|  
 | |
| will use the property "xpath.file" as the file name
 | |
| and the contents of the variable XPATH as the expression to search for.
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| JMeter provides a tool to help you construct
 | |
| function calls for various built-in functions, which you can then copy-paste. 
 | |
| It will not automatically escape values for you, since functions can be parameters to other functions, and you should only escape values you intend as literal.
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| If a string contains a backslash('\') and also contains a function or variable reference, the backslash will be removed if
 | |
| it appears before '$' or ',' or '\'.
 | |
| This behaviour is necessary to allow for nested functions that include commas or the string ${.
 | |
| Backslashes before '$' or ',' or '\' are not removed if the string does not contain a function or variable reference. 
 | |
| 
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| 
 | |
| <b>
 | |
| The value of a variable or function can be reported
 | |
| </b>
 | |
|  using the 
 | |
| <a href="#__logn">
 | |
| __logn()
 | |
| </a>
 | |
|  function.
 | |
| The __logn() function reference can be used anywhere in the test plan after the variable has been defined.
 | |
| Alternatively, the Java Request sampler can be used to create a sample containing variable references;
 | |
| the output will be shown in the appropriate Listener.
 | |
| For versions of JMeter later than 2.3, there is a 
 | |
| <a href="../usermanual/component_reference.html#Debug_Sampler">Debug Sampler</a>
 | |
|  
 | |
| that can be used to display the values of variables etc in the Tree View Listener.
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td><sup>
 | |
| *
 | |
| </sup>
 | |
| If you define a user-defined static variable with the same name as a built-in function, your static
 | |
| variable will override the built-in function.
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| </blockquote>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
 | |
| <tr><td bgcolor="#828DA6">
 | |
| <font color="#ffffff" face="arial,helvetica,sanserif">
 | |
| <a name="function_helper"><strong>19.4 The Function Helper Dialog</strong></a>
 | |
| <a class="sectionlink" href="#function_helper" title="Link to here">¶</a></font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <blockquote>
 | |
| <p>
 | |
| The Function Helper dialog is available from JMeter's Tools menu.
 | |
| </p>
 | |
| <p><table border="0" cellspacing="0" cellpadding="0"><tr><td><img width='667' height='326' src="../images/screenshots/function_helper_dialog.png"><br>
 | |
| <font size="-1">Function Helper Dialog
 | |
| </font></td></tr></table></p>
 | |
| <p>
 | |
| Using the Function Helper, you can select a function from the pull down, and assign
 | |
| values for its arguments.  The left column in the table provides a brief description of the
 | |
| argument, and the right column is where you write in the value for that argument.  Different
 | |
| functions take different arguments.
 | |
| </p>
 | |
| <p>
 | |
| Once you have done this, click the "generate" button, and the appropriate string is generated
 | |
| for you to copy-paste into your test plan wherever you like.
 | |
| </p>
 | |
| </blockquote>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
 | |
| <tr><td bgcolor="#828DA6">
 | |
| <font color="#ffffff" face="arial,helvetica,sanserif">
 | |
| <a name="functions"><strong>19.5 Functions</strong></a>
 | |
| <a class="sectionlink" href="#functions" title="Link to here">¶</a></font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <blockquote>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__regexFunction">19.5.1 __regexFunction</a>
 | |
| <a class="sectionlink" href="#__regexFunction" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <p>
 | |
| The Regex Function is used to parse the previous response (or the value of a variable) using any regular
 | |
| expression (provided by user).  The function returns the template string with variable values filled
 | |
| in.
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| The __regexFunction can also store values for future use.  In the sixth parameter, you can specify
 | |
| a reference name.  After this function executes, the same values can be retrieved at later times
 | |
| using the syntax for user-defined values.  For instance, if you enter "refName" as the sixth
 | |
| parameter you will be able to use:
 | |
| 
 | |
| <ul>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| ${refName} to refer to the computed result of the second parameter ("Template for the
 | |
| replacement string") parsed by this function
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| ${refName_g0} to refer to the entire match  parsed by this function.
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| ${refName_g1} to refer to the first group parsed by this function.
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| ${refName_g#} to refer to the n
 | |
| <sup>
 | |
| th
 | |
| </sup>
 | |
|  group parsed by this function.
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| ${refName_matchNr} to refer to the number of groups found by this function.
 | |
| </li>
 | |
| 
 | |
| 
 | |
| </ul>
 | |
| 
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__regexFunction_parms"/>
 | |
| <a class="sectionlink" href="#__regexFunction_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>First argument</td>
 | |
| <td>The first argument is the regular expression
 | |
|         to be applied to the response data.  It will grab all matches.  Any parts of this expression
 | |
|         that you wish to use in your template string, be sure to surround in parentheses.  Example:
 | |
|         <a href="(.*)">.  This will grab the value of the link and store it as the first group (there is
 | |
|         only 1 group).  Another example: <input type="hidden" name="(.*)" value="(.*)">.  This will
 | |
|         grab the name as the first group, and the value as the second group.  These values can be used
 | |
|         in your template string
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Second argument</td>
 | |
| <td>This is the template string that will replace
 | |
|         the function at run-time.  To refer to a group captured in the regular expression, use the syntax:
 | |
|         $[group_number]$.  Ie: $1$, or $2$.  Your template can be any string.
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Third argument</td>
 | |
| <td>The third argument tells JMeter which match
 | |
|         to use.  Your regular expression might find numerous matches.  You have four choices:
 | |
|                 
 | |
| <ul>
 | |
| <li>
 | |
| An integer - Tells JMeter to use that match.  '1' for the first found match, '2' for the
 | |
|                 second, and so on
 | |
| </li>
 | |
| 
 | |
|                 
 | |
| <li>
 | |
| RAND - Tells JMeter to choose a match at random.
 | |
| </li>
 | |
| 
 | |
|                 
 | |
| <li>
 | |
| ALL - Tells JMeter to use all matches, and create a template string for each one and then
 | |
|                 append them all together.  This option is little used.
 | |
| </li>
 | |
| 
 | |
|                 
 | |
| <li>
 | |
| A float number between 0 and 1 - tells JMeter to find the Xth match using the formula:
 | |
|                 (number_of_matches_found * float_number) rounded to nearest integer.
 | |
| </li>
 | |
| 
 | |
|                 
 | |
| </ul>
 | |
| </td>
 | |
| <td>
 | |
| No, default=1
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Fourth argument</td>
 | |
| <td>If 'ALL' was selected for the above argument
 | |
|         value, then this argument will be inserted between each appended copy of the template value.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Fifth argument</td>
 | |
| <td>Default value returned if no match is found
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Sixth argument</td>
 | |
| <td>A reference name for reusing the values parsed by this function.
 | |
| <br>
 | |
| 
 | |
| 
 | |
|         Stored values are ${refName} (the replacement template string) and ${refName_g#} where "#" is the
 | |
|         group number from the regular expression ("0" can be used to refer to the entire match).
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Seventh argument</td>
 | |
| <td>Input variable name. 
 | |
|         If specified, then the value of the variable is used as the input instead of using the previous sample result.
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__counter">19.5.2 __counter</a>
 | |
| <a class="sectionlink" href="#__counter" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <p>
 | |
| The counter generates a new number each time it is called, starting with 1
 | |
| and incrementing by +1 each time.  The counter can be configured to keep each simulated user's values
 | |
| separate, or to use the same counter for all users.  If each user's values is incremented separately,
 | |
| that is like counting the number of iterations through the test plan.  A global counter is like
 | |
| counting how many times that request was run.
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| The counter uses an integer variable to hold the count, which therefore has a maximum of 2,147,483,647.
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| The counter function instances are now completely independent. 
 | |
| [JMeter 2.1.1 and earlier used a fixed thread variable to keep track of the per-user count, 
 | |
| so multiple counter functions operated on the same value.] 
 | |
| The global counter - "FALSE" - is separately maintained by each counter instance.
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| 
 | |
| <b>
 | |
| 
 | |
| Multiple __counter function calls in the same iteration won't increment the value further.
 | |
| 
 | |
| </b>
 | |
| 
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| If you want to have a count that increments for each sample, use the function in a Pre-Processor such as 
 | |
| <a href="../usermanual/component_reference.html#User_Parameters">User Parameters</a>
 | |
| .
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__counter_parms"/>
 | |
| <a class="sectionlink" href="#__counter_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>First argument</td>
 | |
| <td>TRUE if you wish each simulated user's counter
 | |
|         to be kept independent and separate from the other users.  FALSE for a global counter.
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Second argument</td>
 | |
| <td>A reference name for reusing the value created by this function.
 | |
| <br>
 | |
| 
 | |
| 
 | |
|                 Stored values are of the form ${refName}.  This allows you to keep one counter and refer to its value in
 | |
|                 multiple places. [For JMeter 2.1.1 and earlier this parameter was required.]
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__threadNum">19.5.3 __threadNum</a>
 | |
| <a class="sectionlink" href="#__threadNum" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <p>
 | |
| The thread number function simply returns the number of the thread currently
 | |
| being executed.  These numbers are independent of ThreadGroup, meaning thread #1 in one threadgroup
 | |
| is indistinguishable from thread #1 in another threadgroup, from the point of view of this function.
 | |
| </p>
 | |
| 
 | |
| 
 | |
| 
 | |
| <p>
 | |
| There are no arguments for this function.
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| This function does not work in any Configuration elements (e.g. User Defined Variables) as these are run from a separate thread.
 | |
| Nor does it make sense to use it on the Test Plan.
 | |
| 
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__intSum">19.5.4a __intSum</a>
 | |
| <a class="sectionlink" href="#__intSum" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| The intSum function can be used to compute the sum of two or more integer values.
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| JMeter Versions 2.3.1 and earlier required the reference name to be present.
 | |
| The reference name is now optional, but it must not be a valid integer.
 | |
| 
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__intSum_parms"/>
 | |
| <a class="sectionlink" href="#__intSum_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>First argument</td>
 | |
| <td>The first int value.
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Second argument</td>
 | |
| <td>The second int value.
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>nth argument</td>
 | |
| <td>The nth int value.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>last argument</td>
 | |
| <td>A reference name for reusing the value computed by this function. 
 | |
|                 If specified, the reference name must contain at least one non-numeric character otherwise it will
 | |
|                 be treated as another int value to be added.
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__longSum">19.5.4b __longSum</a>
 | |
| <a class="sectionlink" href="#__longSum" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <p>
 | |
| The longSum function can be used to compute the sum of two or more long values.
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__longSum_parms"/>
 | |
| <a class="sectionlink" href="#__longSum_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>First argument</td>
 | |
| <td>The first long value.
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Second argument</td>
 | |
| <td>The second long value.
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>nth argument</td>
 | |
| <td>The nth long value.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>last argument</td>
 | |
| <td>A reference name for reusing the value computed by this function. 
 | |
|                 If specified, the reference name must contain at least one non-numeric character otherwise it will
 | |
|                 be treated as another long value to be added.
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <a name="_StringFromFile">
 | |
| </a>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__StringFromFile">19.5.5 __StringFromFile</a>
 | |
| <a class="sectionlink" href="#__StringFromFile" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	The StringFromFile function can be used to read strings from a text file. 
 | |
| 	This is useful for running tests that require lots of variable data.
 | |
| 	For example when testing a banking application, 100s or 1000s of different account numbers might be required.
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	See also the 
 | |
| 	
 | |
| <a href="component_reference.html#CSV_Data_Set_Config">
 | |
| CSV Data Set Config test element
 | |
| </a>
 | |
|  
 | |
| 	which may be easier to use. However, that does not currently support multiple input files.
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	Each time it is called it reads the next line from the file.
 | |
|     All threads share the same instance, so different threads will get different lines.
 | |
| 	When the end of the file is reached, it will start reading again from the beginning,
 | |
| 	unless the maximum loop count has been reached.
 | |
| 	If there are multiple references to the function in a test script, each will open the file independently,
 | |
| 	even if the file names are the same.
 | |
| 	[If the value is to be used again elsewhere, use different variable names for each function call.]
 | |
| 	
 | |
| </p>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
|     Function instances are shared between threads, and the file is (re-)opened by whatever thread
 | |
|     happens to need the next line of input, so using the threadNumber as part of the file name
 | |
|     will result in unpredictable behaviour.
 | |
|     
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| If an error occurs opening or reading the file, then the function returns the string "**ERR**"
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__StringFromFile_parms"/>
 | |
| <a class="sectionlink" href="#__StringFromFile_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>File Name</td>
 | |
| <td>Path to the file name.
 | |
|         	(The path can be relative to the JMeter launch directory)
 | |
|         	If using optional sequence numbers, the path name should be suitable for passing to DecimalFormat.
 | |
|         	See below for examples.
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Variable Name</td>
 | |
| <td>
 | |
| A reference name - refName - for reusing the value created by this function. Stored values are of the form ${refName}.
 | |
| Defaults to "StringFromFile_".
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Start sequence number</td>
 | |
| <td>Initial Sequence number (if omitted, the End sequence number is treated as a loop count)
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>End   sequence number</td>
 | |
| <td>Final sequence number (if omitted, seqence numbers can increase without limit)
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| The file name parameter is resolved when the file is opened or re-opened.
 | |
| </p>
 | |
| <p>
 | |
| The reference name parameter (if supplied) is resolved every time the function is executed.
 | |
| </p>
 | |
| <p>
 | |
| <b>
 | |
| Using sequence numbers:
 | |
| </b>
 | |
| </p>
 | |
| <p>
 | |
| When using the optional sequence numbers, the path name is used as the format string for java.text.DecimalFormat.
 | |
| 	The current sequence number is passed in as the only parameter.
 | |
|     If the optional start number is not specified, the path name is used as is.
 | |
| 	Useful formatting sequences are:
 | |
| 	
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| 
 | |
| <code>
 | |
| 
 | |
| # - insert the number, with no leading zeros or spaces
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 000 - insert the number packed out to 3 digits with leading zeros if necessary
 | |
| 
 | |
| <p>
 | |
| </p>
 | |
| 
 | |
| Examples:
 | |
| <br>
 | |
| 
 | |
| 
 | |
|  pin#'.'dat -> pin1.dat, ... pin9.dat, pin10.dat, ... pin9999.dat
 | |
| <br>
 | |
| 
 | |
| 
 | |
|  pin000'.'dat -> pin001.dat ... pin099.dat ... pin999.dat ... pin9999.dat
 | |
| <br>
 | |
| 
 | |
| 
 | |
|  pin'.'dat# -> pin.dat1, ... pin.dat9 ... pin.dat999
 | |
| 
 | |
| </code>
 | |
| <p>
 | |
| </p>
 | |
| 
 | |
| 	If more digits are required than there are formatting characters, the number will be
 | |
| 	expanded as necessary.
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	
 | |
| <b>
 | |
| To prevent a formatting character from being interpreted,
 | |
| 	enclose it in single quotes. Note that "." is a formatting character,
 | |
| 	and must be enclosed in single quotes
 | |
| </b>
 | |
| 
 | |
| 	(though #. and 000. work as expected in locales where the decimal point is also ".")
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	In other locales (e.g. fr), the decimal point is "," - which means that "#."
 | |
| 	becomes "nnn,".
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	See the documentation for DecimalFormat for full details.
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	If the path name does not contain any special formatting characters,
 | |
| 	the current sequence number will be appended to the name, otherwise
 | |
| 	the number will be inserted aaccording to the fomatting instructions.
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	If the start sequence number is omitted, and the end sequence number is specified,
 | |
| 	the sequence number is interpreted as a loop count, and the file will be used at most "end" times.
 | |
| 	In this case the filename is not formatted.
 | |
| 	
 | |
| <code>
 | |
| 
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	${_StringFromFile(PIN#'.'DAT,,1,2)} - reads PIN1.DAT, PIN2.DAT
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	${_StringFromFile(PIN.DAT,,,2)} - reads PIN.DAT twice
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	
 | |
| </code>
 | |
| 
 | |
| 	Note that the "." in PIN.DAT above should 
 | |
| <u>
 | |
| not
 | |
| </u>
 | |
|  be quoted.
 | |
| 	In this case the start number is omitted, so the file name is used exactly as is.
 | |
| 	
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__machineName">19.5.6a __machineName</a>
 | |
| <a class="sectionlink" href="#__machineName" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <p>
 | |
| The machineName function returns the local host name
 | |
| </p>
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__machineName_parms"/>
 | |
| <a class="sectionlink" href="#__machineName_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Variable Name</td>
 | |
| <td>A reference name for reusing the value
 | |
|                 computed by this function.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__machineIP">19.5.6b __machineIP</a>
 | |
| <a class="sectionlink" href="#__machineIP" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <p>
 | |
| The machineIP function returns the local IP address
 | |
| </p>
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__machineIP_parms"/>
 | |
| <a class="sectionlink" href="#__machineIP_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Variable Name</td>
 | |
| <td>A reference name for reusing the value
 | |
|                 computed by this function.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__javaScript">19.5.7 __javaScript</a>
 | |
| <a class="sectionlink" href="#__javaScript" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| The javaScript function executes a piece of JavaScript (not Java!) code and returns its value
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| The JMeter Javascript function calls a standalone JavaScript interpreter.
 | |
| Javascript is used as a scripting language, so you can do calculations etc.
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| For details of the language, please see 
 | |
| <a href="http://www.mozilla.org/rhino/overview.html">
 | |
| Mozilla Rhino Overview
 | |
| </a>
 | |
| 
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| The following variables are made available to the script:
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <ul>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| log - the logger for the function
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| ctx - JMeterContext object
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| vars - JMeterVariables object
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| threadName - String containing the current thread name (in 2.3.2 it was misspelt as "theadName")
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| sampler - current Sampler object (if any)
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| sampleResult - previous SampleResult object (if any)
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| props - JMeter Properties object
 | |
| </li>
 | |
| 
 | |
| 
 | |
| </ul>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| Rhinoscript allows access to static methods via its Packages object.
 | |
| See the 
 | |
| <a href="http://www.mozilla.org/rhino/ScriptingJava.html">
 | |
| Scripting Java
 | |
| </a>
 | |
|  documentation.
 | |
| For example one can access the JMeterContextService static methods thus:
 | |
| 
 | |
| <code>
 | |
| Packages.org.apache.jmeter.threads.JMeterContextService.getTotalThreads()
 | |
| </code>
 | |
| 
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| JMeter is not a browser, and does not interpret the JavaScript in downloaded pages.
 | |
| 
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__javaScript_parms"/>
 | |
| <a class="sectionlink" href="#__javaScript_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Expression</td>
 | |
| <td>The JavaScript expression to be executed. For example:
 | |
|         	
 | |
| <ul>
 | |
| 
 | |
|         		
 | |
| <li>
 | |
| new Date() - return the current date and time
 | |
| </li>
 | |
| 
 | |
|         		
 | |
| <li>
 | |
| Math.floor(Math.random()*(${maxRandom}+1))
 | |
|         			- a random number between 0 and the variable maxRandom
 | |
| </li>
 | |
| 
 | |
|         		
 | |
| <li>
 | |
| ${minRandom}+Math.floor(Math.random()*(${maxRandom}-${minRandom}+1))
 | |
|         			- a random number between the variables minRandom and maxRandom
 | |
| </li>
 | |
| 
 | |
|         		
 | |
| <li>
 | |
| "${VAR}"=="abcd"
 | |
| </li>
 | |
| 
 | |
|         	
 | |
| </ul>
 | |
| 
 | |
|         	
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Variable Name</td>
 | |
| <td>A reference name for reusing the value
 | |
|                 computed by this function.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>Remember to include any necessary quotes for text strings and JMeter variables. Also, if
 | |
| the expression has commas, please make sure to escape them. For example in:
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| ${__javaScript('${sp}'.slice(7\,99999))}
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| the comma after 7 is escaped.
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__Random">19.5.8 __Random</a>
 | |
| <a class="sectionlink" href="#__Random" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <p>
 | |
| The random function returns a random number that lies between the given min and max values.
 | |
| </p>
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__Random_parms"/>
 | |
| <a class="sectionlink" href="#__Random_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Minimum value</td>
 | |
| <td>A number
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Maximum value</td>
 | |
| <td>A bigger number
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Variable Name</td>
 | |
| <td>A reference name for reusing the value
 | |
|                 computed by this function.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__RandomString">19.5.8 __RandomString</a>
 | |
| <a class="sectionlink" href="#__RandomString" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <p>
 | |
| The RandomString function returns a random String of length using characters in chars to use.
 | |
| </p>
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__RandomString_parms"/>
 | |
| <a class="sectionlink" href="#__RandomString_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Length</td>
 | |
| <td>A number length of generated String
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Characters to use</td>
 | |
| <td>Chars used to generate String
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Variable Name</td>
 | |
| <td>A reference name for reusing the value
 | |
|                 computed by this function.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__CSVRead">19.5.8 __CSVRead</a>
 | |
| <a class="sectionlink" href="#__CSVRead" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <p>
 | |
| The CSVRead function returns a string from a CSV file (c.f. 
 | |
| <a href="#_StringFromFile">
 | |
| StringFromFile
 | |
| </a>
 | |
| )
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| NOTE: versions up to 1.9.1 only supported a single file. 
 | |
| 		JMeter versions since 1.9.1 support multiple file names.
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| <b>
 | |
| In most cases, the newer 
 | |
| 	
 | |
| <a href="component_reference.html#CSV_Data_Set_Config">
 | |
| CSV Data Set Config element
 | |
| </a>
 | |
| 
 | |
| 	 is easier to use.
 | |
| </b>
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	When a filename is first encountered, the file is opened and read into an internal
 | |
| 	array. If a blank line is detected, this is treated as end of file - this allows
 | |
| 	trailing comments to be used (N.B. this feature was introduced in versions after 1.9.1)
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| All subsequent references to the same file name use the same internal array.
 | |
| 	N.B. the filename case is significant to the function, even if the OS doesn't care,
 | |
| 	so CSVRead(abc.txt,0) and CSVRead(aBc.txt,0) would refer to different internal arrays.
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	The *ALIAS feature allows the same file to be opened more than once,
 | |
| 	and also allows for shorter file names.
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	Each thread has its own internal pointer to its current row in the file array.
 | |
| 	When a thread first refers to the file it will be allocated the next free row in
 | |
| 	the array, so each thread will access a different row from all other threads.
 | |
| 	[Unless there are more threads than there are rows in the array.]
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	Note: the function splits the line at every comma by default.
 | |
| 	If you want to enter columns containing commas, then you will need
 | |
| 	to change the delimiter to a character that does not appear in any
 | |
| 	column data, by setting the property: csvread.delimiter
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__CSVRead_parms"/>
 | |
| <a class="sectionlink" href="#__CSVRead_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>File Name</td>
 | |
| <td>The file (or *ALIAS) to read from
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Column number</td>
 | |
| <td>
 | |
|         	The column number in the file.
 | |
|         	0 = first column, 1 = second etc.
 | |
|         	"next" - go to next line of file.
 | |
|         	*ALIAS - open a file and assign it to the alias
 | |
|         	
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| For example, you could set up some variables as follows:
 | |
| 
 | |
| <ul>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| COL1a ${__CSVRead(random.txt,0)}
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| COL2a ${__CSVRead(random.txt,1)}${__CSVRead(random.txt,next)}
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| COL1b ${__CSVRead(random.txt,0)}
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| COL2b ${__CSVRead(random.txt,1)}${__CSVRead(random.txt,next)}
 | |
| </li>
 | |
| 
 | |
| 
 | |
| </ul>
 | |
| 
 | |
| This would read two columns from one line, and two columns from the next available line.
 | |
| If all the variables are defined on the same User Parameters Pre-Processor, then the lines
 | |
| will be consecutive. Otherwise, a different thread may grab the next line.
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| The function is not suitable for use with large files, as the entire file is stored in memory.
 | |
| For larger files, use 
 | |
| <a href="component_reference.html#CSV_Data_Set_Config">
 | |
| CSV Data Set Config element
 | |
| </a>
 | |
| 
 | |
| or 
 | |
| <a href="#__StringFromFile">
 | |
| StringFromFile
 | |
| </a>
 | |
| .
 | |
| 
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__property">19.5.9 __property</a>
 | |
| <a class="sectionlink" href="#__property" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <p>
 | |
| 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.
 | |
| 	When supplying a default value, there is no need to provide a function name - the parameter can be set to null, and it will be ignored.
 | |
| 	
 | |
| </p>
 | |
| For example:
 | |
| <p>
 | |
| 
 | |
| 		
 | |
| <ul>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| ${__property(user.dir)} - return value of user.dir
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| ${__property(user.dir,UDIR)} - return value of user.dir and save in UDIR
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| ${__property(abcd,ABCD,atod)} - return value of property abcd (or "atod" if not defined) and save in ABCD
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| ${__property(abcd,,atod)} - return value of property abcd (or "atod" if not defined) but don't save it
 | |
| </li>
 | |
| 
 | |
| 
 | |
| </ul>
 | |
| 
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__property_parms"/>
 | |
| <a class="sectionlink" href="#__property_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Property Name</td>
 | |
| <td>The property name to be retrieved.
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Variable Name</td>
 | |
| <td>A reference name for reusing the value
 | |
|                 computed by this function.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Default Value</td>
 | |
| <td>The default value for the property.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__P">19.5.10 __P</a>
 | |
| <a class="sectionlink" href="#__P" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <p>
 | |
| This is a simplified property function which is
 | |
| 	intended for use with properties defined on the command line.
 | |
| 	Unlike the __property function, there is no option to save the value in a variable,
 | |
| 	and if no default value is supplied, it is assumed to be 1. 
 | |
| 	The value of 1 was chosen because it is valid for common test variables such
 | |
| 	as loops, thread count, ramp up etc.
 | |
| 	
 | |
| </p>
 | |
| For example:
 | |
| <p>
 | |
| 
 | |
| 
 | |
| <code>
 | |
| 
 | |
| Define the property value:
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| jmeter -Jgroup1.threads=7 -Jhostname1=www.realhost.edu
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 
 | |
| Fetch the values:
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| ${__P(group1.threads)} - return the value of group1.threads
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| ${__P(group1.loops)} - return the value of group1.loops
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| ${__P(hostname,www.dummy.org)} - return value of property hostname or www.dummy.org if not defined
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 
 | |
| </code>
 | |
| 
 | |
| In the examples above, the first function call would return 7, 
 | |
| the second would return 1 and the last would return www.dummy.org
 | |
| (unless those properties were defined elsewhere!)
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__P_parms"/>
 | |
| <a class="sectionlink" href="#__P_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Property Name</td>
 | |
| <td>The property name to be retrieved.
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Default Value</td>
 | |
| <td>The default value for the property.
 | |
|         	If omitted, the default is set to "1".
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__log">19.5.11 __log</a>
 | |
| <a class="sectionlink" href="#__log" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	The log function logs a message, and returns its input string
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__log_parms"/>
 | |
| <a class="sectionlink" href="#__log_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>String to be logged</td>
 | |
| <td>A string
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Log Level</td>
 | |
| <td>OUT, ERR, DEBUG, INFO (default), WARN or ERROR
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Throwable text</td>
 | |
| <td>If non-empty, creates a Throwable to pass to the logger
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Comment</td>
 | |
| <td>If present, it is displayed in the string. 
 | |
|         Useful for identifying what is being logged.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| The OUT and ERR log level names are used to direct the output to System.out and System.err respectively.
 | |
| 	In this case, the output is always printed - it does not depend on the current log setting.
 | |
| 
 | |
| </p>
 | |
| <pre>
 | |
| 
 | |
| For example:
 | |
|      ${__log(Message)} - written to the log file as   "...thread Name : Message"
 | |
|      ${__log(Message,OUT)} - written to console window
 | |
|      ${__log(${VAR},,,VAR=)} - written to log file as "...thread Name VAR=value"
 | |
| 
 | |
| </pre>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__logn">19.5.12 __logn</a>
 | |
| <a class="sectionlink" href="#__logn" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	The logn function logs a message, and returns the empty string
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__logn_parms"/>
 | |
| <a class="sectionlink" href="#__logn_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>String to be logged</td>
 | |
| <td>A string
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Log Level</td>
 | |
| <td>OUT, ERR, DEBUG, INFO (default), WARN or ERROR
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Throwable text</td>
 | |
| <td>If non-empty, creates a Throwable to pass to the logger
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| The OUT and ERR log level names are used to direct the output to System.out and System.err respectively.
 | |
| 	In this case, the output is always printed - it does not depend on the current log setting.
 | |
| 
 | |
| </p>
 | |
| <pre>
 | |
| 
 | |
| For example:
 | |
|      ${__logn(VAR1=${VAR1},OUT)} - write the value of the variable to the console window
 | |
| 
 | |
| </pre>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__BeanShell">19.5.13 __BeanShell</a>
 | |
| <a class="sectionlink" href="#__BeanShell" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	The BeanShell function evaluates the script passed to it, and returns the result.
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| 
 | |
| <b>
 | |
| For full details on using BeanShell, please see the BeanShell web-site at 
 | |
| <a href="http://www.beanshell.org/">
 | |
| http://www.beanshell.org/
 | |
| </a>
 | |
| 
 | |
| 
 | |
| </b>
 | |
| 
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| Note that a different Interpreter is used for each independent occurence of the function
 | |
| in a test script, but the same Interpreter is used for subsequent invocations.
 | |
| This means that variables persist across calls to the function.
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| A single instance of a function may be called from multiple threads.
 | |
| However the function execute() method is synchronised.
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| If the property "beanshell.function.init" is defined, it is passed to the Interpreter
 | |
| as the name of a sourced file. This can be used to define common methods and variables. There is a
 | |
| sample init file in the bin directory: BeanShellFunction.bshrc.
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| The following variables are set before the script is executed:
 | |
| 
 | |
| <ul>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| log - the logger for the BeanShell function (*)
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| ctx - the current JMeter context variable
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| vars - the current JMeter variables
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| props - JMeter Properties object
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| threadName - the threadName (String)
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| Sampler the current Sampler, if any
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| SampleResult - the current SampleResult, if any
 | |
| </li>
 | |
| 
 | |
| 
 | |
| </ul>
 | |
| 
 | |
| (*) means that this is set before the init file, if any, is processed. 
 | |
| Other variables vary from invocation to invocation.
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__BeanShell_parms"/>
 | |
| <a class="sectionlink" href="#__BeanShell_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>BeanShell script</td>
 | |
| <td>A beanshell script (not a file name)
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Name of variable</td>
 | |
| <td>A reference name for reusing the value
 | |
|                computed by this function.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| Example:
 | |
| 
 | |
| <pre>
 | |
| 
 | |
| ${__BeanShell(123*456)} - returns 56088
 | |
| ${__BeanShell(source("function.bsh"))} - processes the script in function.bsh
 | |
| 
 | |
| </pre>
 | |
| 
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| Remember to include any necessary quotes for text strings and JMeter variables that represent text strings.
 | |
| 
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__split">19.5.14 __split</a>
 | |
| <a class="sectionlink" href="#__split" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	The split function splits the string passed to it according to the delimiter,
 | |
|     and returns the original string. If any delimiters are adjacent, "?" is returned as the value.
 | |
|     The split strings are returned in the variables ${VAR_1}, ${VAR_2} etc. 
 | |
|     The count of variables is returned in ${VAR_n}. 
 | |
|     From JMeter 2.1.2 onwards, a trailing delimiter is treated as a missing variable, and "?" is returned.
 | |
|     Also, to allow it to work better with the ForEach controller, 
 | |
|     __split now deletes the first unused variable in case it was set by a previous split.
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| </p>
 | |
| 
 | |
| 	Example:
 | |
| 	
 | |
| <code>
 | |
| 
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	Define VAR="a||c|" in the test plan.
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	${__split(${VAR},VAR,|)}
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	This will return the contents of VAR, i.e. "a||c|" and set the following variables:
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
|         VAR_n=4 (3 in JMeter 2.1.1 and earlier)
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
|         VAR_1=a
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
|         VAR_2=?
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
|         VAR_3=c
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
|         VAR_4=? (null in JMeter 2.1.1 and earlier)
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
|         VAR_5=null (in JMeter 2.1.2 and later)
 | |
| 	
 | |
| </code>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__split_parms"/>
 | |
| <a class="sectionlink" href="#__split_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>String to split</td>
 | |
| <td>A delimited string, e.g. "a|b|c"
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Name of variable</td>
 | |
| <td>A reference name for reusing the value
 | |
|                computed by this function.
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Delimiter</td>
 | |
| <td>The delimiter character, e.g. 
 | |
| <b>
 | |
| |
 | |
| </b>
 | |
| . 
 | |
| If omitted, 
 | |
| <b>
 | |
| ,
 | |
| </b>
 | |
|  is used. Note that 
 | |
| <b>
 | |
| ,
 | |
| </b>
 | |
|  would need to be specified as 
 | |
| <b>
 | |
| \,
 | |
| </b>
 | |
| .
 | |
| 
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__XPath">19.5.15 __XPath</a>
 | |
| <a class="sectionlink" href="#__XPath" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	The XPath function reads an XML file and matches the XPath.
 | |
| 	Each time the function is called, the next match will be returned.
 | |
| 	At end of file, it will wrap around to the start.
 | |
| 	If no nodes matched, then the function will return the empty string,
 | |
| 	and a warning message will be written to the JMeter log file.
 | |
| 	
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>Note that the entire NodeList is held in memory.
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| </p>
 | |
| 
 | |
| 	Example:
 | |
| 	
 | |
| <code>
 | |
| 
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 		
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	${__XPath(/path/to/build.xml, //target/@name)}
 | |
| 	
 | |
| <br>
 | |
| 
 | |
| 
 | |
| 	This will match all targets in build.xml and return the contents of the next name attribute
 | |
| 	
 | |
| </code>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__XPath_parms"/>
 | |
| <a class="sectionlink" href="#__XPath_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>XML file to parse</td>
 | |
| <td> a XML file to parse
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>XPath</td>
 | |
| <td> a XPath expression to match nodes in the XML file
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__setProperty">19.5.16 __setProperty</a>
 | |
| <a class="sectionlink" href="#__setProperty" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| The setProperty function sets the value of a JMeter property. 
 | |
| 		The default return value from the function is the empty string,
 | |
| 		so the function call can be used anywhere functions are valid.
 | |
| </p>
 | |
| 
 | |
|         
 | |
| <p>
 | |
| The original value can be returned by setting the optional 3rd parameter to "true".
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| Properties are global to JMeter,
 | |
| 		so can be used to communicate between threads and thread groups
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__setProperty_parms"/>
 | |
| <a class="sectionlink" href="#__setProperty_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Property Name</td>
 | |
| <td>The property name to be set.
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Property Value</td>
 | |
| <td>The value for the property.
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>True/False</td>
 | |
| <td>Should the original value be returned?
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__time">19.5.17 __time</a>
 | |
| <a class="sectionlink" href="#__time" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| The time function returns the current time in various formats.
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__time_parms"/>
 | |
| <a class="sectionlink" href="#__time_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Format</td>
 | |
| <td>
 | |
|         The format to be passed to SimpleDateFormat. 
 | |
|         The function supports various shorthand aliases, see below.
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Name of variable</td>
 | |
| <td>The name of the variable to set.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| If the format string is omitted, then the function returns the current time in milliseconds.
 | |
| Otherwise, the current time is passed to SimpleDateFormat.
 | |
| The following shorthand aliases are provided:
 | |
| 
 | |
| </p>
 | |
| <ul>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| YMD = yyyyMMdd
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| HMS = HHmmss
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| YMDHMS = yyyyMMdd-HHmmss
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| USER1 = whatever is in the Jmeter property time.USER1
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| USER2 = whatever is in the Jmeter property time.USER2
 | |
| </li>
 | |
| 
 | |
| 
 | |
| </ul>
 | |
| <p>
 | |
| The defaults can be changed by setting the appropriate JMeter property, e.g.
 | |
| time.YMD=yyMMdd
 | |
| 
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__jexl">19.5.18 __jexl</a>
 | |
| <a class="sectionlink" href="#__jexl" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| The jexl function returns the result of evaluating a 
 | |
| 	
 | |
| <a href="http://commons.apache.org/jexl">
 | |
| Commons JEXL expression
 | |
| </a>
 | |
| . 
 | |
| 	See links below for more information on JEXL expressions.
 | |
| 	
 | |
| </p>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| The __jexl function uses Commons JEXL 1, and the __jexl2 function uses Commons JEXL 2
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <ul>
 | |
| 
 | |
| 	
 | |
| <li>
 | |
| <a href="http://commons.apache.org/jexl/reference/syntax.html">
 | |
| JEXL syntax description
 | |
| </a>
 | |
| </li>
 | |
| 
 | |
| 	
 | |
| <li>
 | |
| <a href="http://commons.apache.org/jexl/reference/examples.html#Example_Expressions">
 | |
| JEXL examples
 | |
| </a>
 | |
| </li>
 | |
| 
 | |
| 	
 | |
| </ul>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__jexl_parms"/>
 | |
| <a class="sectionlink" href="#__jexl_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Expression</td>
 | |
| <td>
 | |
|         The expression to be evaluated. For example, 6*(5+2)
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Name of variable</td>
 | |
| <td>The name of the variable to set.
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| The following variables are made available to the script:
 | |
| 
 | |
| </p>
 | |
| <ul>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| log - the logger for the function
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| ctx - JMeterContext object
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| vars - JMeterVariables object
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| props - JMeter Properties object
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| threadName - String containing the current thread name (in 2.3.2 it was misspelt as "theadName")
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| sampler - current Sampler object (if any)
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| sampleResult - previous SampleResult object (if any)
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| OUT - System.out - e.g. OUT.println("message")
 | |
| </li>
 | |
| 
 | |
| 
 | |
| </ul>
 | |
| <p>
 | |
| 
 | |
|     Jexl can also create classes and call methods on them, for example:
 | |
|     
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
|     
 | |
| <code>
 | |
| 
 | |
|     Systemclass=log.class.forName("java.lang.System");
 | |
| <br>
 | |
| 
 | |
| 
 | |
|     now=Systemclass.currentTimeMillis();
 | |
|     
 | |
| </code>
 | |
| 
 | |
|     Note that the Jexl documentation on the web-site wrongly suggests that "div" does integer division.
 | |
|     In fact "div" and "/" both perform normal division. One can get the same effect
 | |
|     as follows:
 | |
|     
 | |
| <code>
 | |
| 
 | |
|     i= 5 / 2;
 | |
|     i.intValue(); // or use i.longValue()
 | |
|     
 | |
| </code>
 | |
| 
 | |
|     
 | |
| </p>
 | |
| <p>
 | |
| <table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
 | |
| <tr><td>Versions of JMeter after 2.3.2 allow the expression to contain multiple statements.
 | |
|     JMeter 2.3.2 and earlier only processed the first statement (if there were multiple statements a warning was logged).
 | |
|     
 | |
| </td></tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__V">19.5.19 __V</a>
 | |
| <a class="sectionlink" href="#__V" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| The V (variable) function returns the result of evaluating a variable name expression.
 | |
| 	This can be used to evaluate nested variable references (which are not currently supported).
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| For example, if one has variables A1,A2 and N=1:
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <ul>
 | |
| 
 | |
| 	
 | |
| <li>
 | |
| ${A1} - works OK
 | |
| </li>
 | |
| 
 | |
| 	
 | |
| <li>
 | |
| ${A${N}} - does not work (nested variable reference)
 | |
| </li>
 | |
| 
 | |
| 	
 | |
| <li>
 | |
| ${__V(A${N})} - works OK. A${N} becomes A1, and the __V function returns the value of A1
 | |
| </li>
 | |
| 
 | |
| 	
 | |
| </ul>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__V_parms"/>
 | |
| <a class="sectionlink" href="#__V_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Variable name</td>
 | |
| <td>
 | |
|         The variable to be evaluated. 
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__evalVar">19.5.20 __evalVar</a>
 | |
| <a class="sectionlink" href="#__evalVar" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| The eval function returns the result of evaluating an expression stored in a variable.
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	This allows one to read a string from a file, and process any variable references in it.
 | |
| 	For example, if the variable "query" contains "select ${column} from ${table}" 
 | |
| 	and "column" and "table" contain "name" and "customers", then ${__evalVar(query)}
 | |
| 	will evaluate as "select name from customers". 
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__evalVar_parms"/>
 | |
| <a class="sectionlink" href="#__evalVar_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Variable name</td>
 | |
| <td>
 | |
|         The variable to be evaluated. 
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__eval">19.5.21 __eval</a>
 | |
| <a class="sectionlink" href="#__eval" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| The eval function returns the result of evaluating a string expression.
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	This allows one to interpolate variable and function references in a string
 | |
| 	which is stored in a variable.	For example, given the following variables:
 | |
| 	
 | |
| <ul>
 | |
| 
 | |
| 	
 | |
| <li>
 | |
| name=Smith
 | |
| </li>
 | |
| 
 | |
| 	
 | |
| <li>
 | |
| column=age
 | |
| </li>
 | |
| 
 | |
| 	
 | |
| <li>
 | |
| table=birthdays
 | |
| </li>
 | |
| 
 | |
| 	
 | |
| <li>
 | |
| SQL=select ${column} from ${table} where name='${name}'
 | |
| </li>
 | |
| 
 | |
| 	
 | |
| </ul>
 | |
| 
 | |
| 	then ${__eval(${SQL})} will evaluate as "select age from birthdays where name='Smith'". 
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| 
 | |
| 	This can be used in conjunction with CSV Dataset, for example 
 | |
| 	where the both SQL statements and the values are defined in the data file.
 | |
| 	
 | |
| </p>
 | |
| 
 | |
| 	
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__eval_parms"/>
 | |
| <a class="sectionlink" href="#__eval_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Variable name</td>
 | |
| <td>
 | |
|         The variable to be evaluated. 
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__char">19.5.22 __char</a>
 | |
| <a class="sectionlink" href="#__char" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| 
 | |
|     The char function returns the result of evaluating a list of numbers as Unicode characters.
 | |
|     See also __unescape(), below.
 | |
|     
 | |
| </p>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| 
 | |
|     This allows one to add arbitrary character values into fields.
 | |
|     
 | |
| </p>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__char_parms"/>
 | |
| <a class="sectionlink" href="#__char_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Unicode character number (decimal or 0xhex)</td>
 | |
| <td>
 | |
|         The decimal number (or hex number, if prefixed by 0x, or octal, if prefixed by 0) to be converted to a Unicode character.
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| Examples:
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| ${__char(13,10)} = ${__char(0xD,0xA)} = ${__char(015,012)} = CRLF
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| ${__char(165)} = ¥ (yen)
 | |
|  
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__unescape">19.5.23 __unescape</a>
 | |
| <a class="sectionlink" href="#__unescape" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| 
 | |
|     The unescape function returns the result of evaluating a Java-escaped string. See also __char() above.
 | |
|     
 | |
| </p>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| 
 | |
|     This allows one to add characters to fields which are otherwise tricky (or impossible) to define via the GUI.
 | |
|     
 | |
| </p>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__unescape_parms"/>
 | |
| <a class="sectionlink" href="#__unescape_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>String to unescape</td>
 | |
| <td>
 | |
|         The string to be unescaped.
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| Examples:
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| ${__unescape(\r\n)} = CRLF
 | |
| 
 | |
| <br>
 | |
| 
 | |
| 
 | |
| ${__unescape(1\t2)} = 1[tab]2
 | |
|  
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__unescapeHtml">19.5.24 __unescapeHtml</a>
 | |
| <a class="sectionlink" href="#__unescapeHtml" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| 
 | |
| Function to unescape a string containing HTML entity escapes
 | |
| to a string containing the actual Unicode characters corresponding to the escapes. 
 | |
| Supports HTML 4.0 entities.
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| For example, the string 
 | |
| <code>
 | |
| "&lt;Fran&ccedil;ais&gt;"
 | |
| </code>
 | |
| 
 | |
| will become 
 | |
| <code>
 | |
| "<Français>"
 | |
| </code>
 | |
| .
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| If an entity is unrecognized, it is left alone, and inserted verbatim into the result string.
 | |
| e.g. 
 | |
| <code>
 | |
| ">&zzzz;x"
 | |
| </code>
 | |
|  will become 
 | |
| <code>
 | |
| ">&zzzz;x"
 | |
| </code>
 | |
| .
 | |
| 
 | |
| </p>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| 
 | |
|     Uses StringEscapeUtils#unescapeHtml(String) from Commons Lang.
 | |
|     
 | |
| </p>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__unescapeHtml_parms"/>
 | |
| <a class="sectionlink" href="#__unescapeHtml_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>String to unescape</td>
 | |
| <td>
 | |
|         The string to be unescaped.
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__escapeHtml">19.5.25 __escapeHtml</a>
 | |
| <a class="sectionlink" href="#__escapeHtml" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| 
 | |
| Function which escapes the characters in a String using HTML entities.
 | |
| Supports HTML 4.0 entities.
 | |
| 
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| 
 | |
| For example,
 | |
| <code>
 | |
| "bread" & "butter"
 | |
| </code>
 | |
| 
 | |
| becomes:
 | |
| 
 | |
| <code>
 | |
| &quot;bread&quot; &amp; &quot;butter&quot;
 | |
| </code>
 | |
| .
 | |
| 
 | |
| </p>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| 
 | |
|     Uses StringEscapeUtils#escapeHtml(String) from Commons Lang.
 | |
|     
 | |
| </p>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__escapeHtml_parms"/>
 | |
| <a class="sectionlink" href="#__escapeHtml_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>String to escape</td>
 | |
| <td>
 | |
|         The string to be escaped.
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__FileToString">19.5.26 __FileToString</a>
 | |
| <a class="sectionlink" href="#__FileToString" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| 
 | |
|     The FileToString function can be used to read an entire file.
 | |
|     Each time it is called it reads the entire file.
 | |
|     
 | |
| </p>
 | |
|  
 | |
|     
 | |
| <p>
 | |
| If an error occurs opening or reading the file, then the function returns the string "**ERR**"
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__FileToString_parms"/>
 | |
| <a class="sectionlink" href="#__FileToString_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>File Name</td>
 | |
| <td>Path to the file name.
 | |
|             (The path can be relative to the JMeter launch directory)
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| Yes
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>File encoding if not the platform default</td>
 | |
| <td>
 | |
|         The encoding to be used to read the file. If not specified, the platform default is used.
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| <tr>
 | |
| <td>Variable Name</td>
 | |
| <td>
 | |
| A reference name - refName - for reusing the value created by this function. Stored values are of the form ${refName}.
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| <p>
 | |
| The file name, encoding and reference name parameters are resolved every time the function is executed.
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__samplerName">19.5.27 __samplerName</a>
 | |
| <a class="sectionlink" href="#__samplerName" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| 
 | |
|     The samplerName function returns the name (i.e. label) of the current sampler.
 | |
|     
 | |
| </p>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| 
 | |
|     The function does not work in Test elements that don't have an associated sampler.
 | |
|     For example the Test Plan. 
 | |
|     Configuration elements also don't have an associated sampler.
 | |
|     However some Configuration elements are referenced directly by samplers, such as the HTTP Header Manager
 | |
|     and Http Cookie Manager, and in this case the functions are resolved in the context of the Http Sampler.
 | |
|     Pre-Processors, Post-Processors and Assertions always have an associated Sampler.
 | |
|     
 | |
| </p>
 | |
| 
 | |
| 
 | |
| <p>
 | |
| <b>Parameters</b>
 | |
| <a name="__samplerName_parms"/>
 | |
| <a class="sectionlink" href="#__samplerName_parms" title="Link to here">¶</a><table border="1" cellspacing="0" cellpadding="2">
 | |
| <tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 | |
| <tr>
 | |
| <td>Variable Name</td>
 | |
| <td>
 | |
| A reference name - refName - for reusing the value created by this function. Stored values are of the form ${refName}.
 | |
|         
 | |
| </td>
 | |
| <td>
 | |
| No
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| <table border="0" cellspacing="0" cellpadding="2">
 | |
| <tr><td>
 | |
| <font face="arial,helvetica,sanserif">
 | |
| <h3>
 | |
| <a name="__TestPlanName">19.5.28 __TestPlanName</a>
 | |
| <a class="sectionlink" href="#__TestPlanName" title="Link to here">¶</a></h3>
 | |
| </font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| 
 | |
|     
 | |
| <p>
 | |
| 
 | |
|     The TestPlanName function returns the name of the current test plan (can be used in Including Plans to know the name of the calling test plan).
 | |
|     
 | |
| </p>
 | |
| 
 | |
| 
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <hr>
 | |
| </blockquote>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
 | |
| <tr><td bgcolor="#828DA6">
 | |
| <font color="#ffffff" face="arial,helvetica,sanserif">
 | |
| <a name="predefinedvars"><strong>19.6 Pre-defined Variables</strong></a>
 | |
| <a class="sectionlink" href="#predefinedvars" title="Link to here">¶</a></font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <blockquote>
 | |
| <p>
 | |
| 
 | |
| Most variables are set by calling functions or by test elements such as User Defined Variables; 
 | |
| in which case the user has full control over the variable name that is used.
 | |
| However some variables are defined internally by JMeter. These are listed below.
 | |
| 
 | |
| </p>
 | |
| <ul>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| COOKIE_cookiename - contains the cookie value (see 
 | |
| <a href="../usermanual/component_reference.html#HTTP_Cookie_Manager">HTTP Cookie Manager</a>
 | |
| )
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| JMeterThread.last_sample_ok - whether or not the last sample was OK - true/false.
 | |
| Note: this is updated after PostProcessors and Assertions have been run.
 | |
| 
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| START variables (see next section)
 | |
| </li>
 | |
| 
 | |
| 
 | |
| </ul>
 | |
| </blockquote>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
 | |
| <tr><td bgcolor="#828DA6">
 | |
| <font color="#ffffff" face="arial,helvetica,sanserif">
 | |
| <a name="predefinedprops"><strong>19.6 Pre-defined Properties</strong></a>
 | |
| <a class="sectionlink" href="#predefinedprops" title="Link to here">¶</a></font>
 | |
| </td></tr>
 | |
| <tr><td>
 | |
| <blockquote>
 | |
| <p>
 | |
| 
 | |
| The set of JMeter properties is initialised from the system properties defined when JMeter starts;
 | |
| additional JMeter properties are defined in jmeter.properties, user.properties or on the command line.
 | |
| 
 | |
| </p>
 | |
| <p>
 | |
| 
 | |
| Some built-in properties are defined by JMeter. These are listed below.
 | |
| For convenience, the START properties are also copied to variables with the same names.
 | |
| 
 | |
| </p>
 | |
| <ul>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| START.MS - JMeter start time in milliseconds
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| START.YMD - JMeter start time as yyyyMMdd
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| START.HMS - JMeter start time as HHmmss
 | |
| </li>
 | |
| 
 | |
| 
 | |
| <li>
 | |
| TESTSTART.MS - test start time in milliseconds
 | |
| </li>
 | |
| 
 | |
| 
 | |
| </ul>
 | |
| <p>
 | |
| 
 | |
| Please note that the START variables / properties represent JMeter startup time, not the test start time.
 | |
| They are mainly intended for use in file names etc.
 | |
| 
 | |
| </p>
 | |
| </blockquote>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| </blockquote>
 | |
| </p>
 | |
| </td></tr>
 | |
| <tr><td><br></td></tr>
 | |
| </table>
 | |
| <table>
 | |
| <tr>
 | |
| <td bgcolor="#525D76">
 | |
| <div align="right"><a href="index.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Index</font></a></div>
 | |
| </td>
 | |
| <td bgcolor="#525D76">
 | |
| <div align="right"><a href="regular_expressions.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Next</font></a></div>
 | |
| </td>
 | |
| <td bgcolor="#525D76">
 | |
| <div align="right"><a href="component_reference.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Prev</font></a></div>
 | |
| </td>
 | |
| </tr>
 | |
| </table>
 | |
| <br>
 | |
| </td>
 | |
| </tr>
 | |
| <tr><td colspan="2">
 | |
| <hr noshade size="1"/>
 | |
| </td></tr>
 | |
| <tr><td colspan="2">
 | |
| <div align="center"><font color="#525D76" size="-1"><em>
 | |
| Copyright © 1999-2012, Apache Software Foundation
 | |
| </em></font></div>
 | |
| </td></tr>
 | |
| <tr><td colspan="2">
 | |
| <div align="center"><font color="#525D76" size="-1">
 | |
| Apache, Apache JMeter, JMeter, the Apache feather, and the Apache JMeter logo are
 | |
| trademarks of the Apache Software Foundation.
 | |
| </font>
 | |
| </div>
 | |
| </td></tr>
 | |
| </table>
 | |
| </body>
 | |
| </html>
 | |
| <!-- end the processing -->
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 |