jmeter_proxy_step_by_step.html 15.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
<!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.
-->

<!-- start the processing -->
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../docs/css/style.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="author" value="JMeter developers">
<meta name="email" value="dev@jmeter.apache.org">

<title>Apache JMeter - Apache JMeter HTTP(S) Test Script Recorder</title>
<style>
  .code { font-weight: bold; }
</style>
</head>

<body bgcolor="#ffffff" text="#000000" link="#525D76">
<table border="0" cellspacing="0">
<tr>
<td align="left">
<a href="http://www.apache.org"><img style="margin: 0px 30px 0px 0px" title="Apache Software Foundation" width="261" height="106" src="../../docs/images/asf-logo.png" border="0"/></a>
</td>
<td align="right">
<a href="http://jmeter.apache.org/"><img width="259" height="88" src="../../docs/images/jmeter.png" alt="Apache JMeter" title="Apache JMeter" border="0"/></a>
</td>
</tr>
</table>
<table border="0" cellspacing="4">
<tr><td>
<hr noshade size="1"/>
</td></tr>
<tr>
<td 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="junitsampler_tutorial.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Next</font></a></div>
</td>
<td bgcolor="#525D76">
<div align="right"><a href="jmeter_distributed_testing_step_by_step.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="script-recorder"><strong>27. Apache JMeter HTTP(S) Test Script Recorder</strong></a></font>
</td></tr>
<tr><td>
<blockquote>
<p>
This tutorial attempts to explain the exact steps for recording HTTP/HTTPS. For those new to JMeter, one easy way to create a test plan is to use the Recorder.
</p><table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="configuration"><strong>27.1 JMeter configuration</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Since JMeter 2.10, recording has been improved to better handle embedded resources and creation of certificates on the fly.
To enable these features, JMeter uses <tt class="code">keytool</tt> utility (available in JRE/JDK) so you need to ensure your
configuration is correct, read <a href="https://wiki.apache.org/jmeter/TestRecording210">this wiki page before starting.</a>
</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="basic-instructions"><strong>27.2 Basic Instructions</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<ol>
  <li>Go to <tt class="code">JMETER_HOME/bin</tt> and start JMeter with <tt class="code">jmeterw.cmd</tt> on Windows
      and <tt class="code">jmeter</tt> on Linux/Unix</li>
  <li>Select <tt class="code">Templates...</tt> on the menu bar</li>
  <table border="0" cellspacing="0" cellpadding="0"><tr><td><img  src="../../docs/images/screenshots/Select-Templates-Icon.png"/><br>
<font size="-1"></font></td></tr></table>

  <li>Select <tt class="code">Recording template</tt> on the list</li>
  <table border="0" cellspacing="0" cellpadding="0"><tr><td><img  src="../../docs/images/screenshots/Select-Recording-Template.png"/><br>
<font size="-1"></font></td></tr></table>

  <li>A complete <tt class="code">Test Plan</tt> is generated</li>
  <table border="0" cellspacing="0" cellpadding="0"><tr><td><img  src="../../docs/images/screenshots/Test_Generated.png"/><br>
<font size="-1"></font></td></tr></table>

  <li>In the <tt class="code">HTTP Request Defaults</tt> element:
    <dl>
      <dt><tt class="code">Server name</tt></dt><dd>enter <tt class="code">example.com</tt></dd>
      <dt><tt class="code">Path</tt></dt><dd>leave blank</dd>
    </dl>
    <table border="0" cellspacing="0" cellpadding="0"><tr><td><img  src="../../docs/images/screenshots/http-config/http-request-defaults.png"/><br>
<font size="-1"></font></td></tr></table>

  </li>
  <li>Return to <tt class="code">HTTP(S) Test Script Recorder</tt>, and click the <tt class="code">Start</tt> button at the top.</li>
  <table border="0" cellspacing="0" cellpadding="0"><tr><td><img  src="../../docs/images/screenshots/Proxy_Run.png"/><br>
<font size="-1"></font></td></tr></table>

</ol><p>
This will start the JMeter proxy server which is used to intercept the browser requests.
A file called <tt class="code">ApacheJMeterTemporaryRootCA.crt</tt> will be generated in <tt class="code">jmeter/bin</tt>
folder. Install this certificate in your browser, if you don't know how to do it,
read <a href="component_reference.html#HTTP%28S%29_Test_Script_Recorder">Installing the JMeter CA certificate for HTTPS recording</a>
</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="configue-browser"><strong>27.3 Configure your browser to use the JMeter Proxy</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
At this point, JMeter's proxy is running. For this exercise, we will use Iceweasel/Firefox
to view some pages on the JMeter website.
</p><ol>
  <li>Start Iceweasel/Firefox, but do not close JMeter.</li>
  <li>From the tool bar, click 
       <span class="menuchoice">
 <span class="guimenuitem">Edit</span>&nbsp;&rarr;&nbsp;<span class="guimenuitem">Preferences</span>  </span>
 (or 
       <span class="menuchoice">
 <span class="guimenuitem">Tools</span>&nbsp;&rarr;&nbsp;<span class="guimenuitem">Preferences</span>  </span>
 or type <tt class="code">about:preferences#advanced</tt>
      as URL). This should bring up the options.
    <table border="0" cellspacing="0" cellpadding="0"><tr><td><img width='914' height='566' src="../../docs/images/screenshots/firefox-network-settings.png"/><br>
<font size="-1"></font></td></tr></table>

  </li>
  <li>Select the <tt class="code">Advanced</tt> tab, and <tt class="code">Network</tt> tab</li>
  <li>Click <tt class="code">Settings</tt> button near the top.</li>
  <li>On the new pop-up, check <tt class="code">Manual proxy configuration</tt>. The address and
      port fields should be enabled now.
    <dl>
      <dt><tt class="code">Address</tt></dt><dd>enter <tt class="code">localhost</tt> or the IP address of your system</dd>
      <dt><tt class="code">Port</tt></dt><dd>enter <tt class="code">8888</tt>.</dd>
    </dl>
    <table border="0" cellspacing="0" cellpadding="0"><tr><td><img width='532' height='240' src="../../docs/images/screenshots/firefox-configure-proxy.png"/><br>
<font size="-1"></font></td></tr></table>

  </li>
  <li>Check <tt class="code">Use this proxy server for all protocols</tt></li>
  <li>Click <tt class="code">OK</tt> button. This should return you to the browser</li>
</ol></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="navigation-recording"><strong>27.4 Record your navigation</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<ol>
  <li>With your browser, in the <tt class="code">Address</tt> bar at the top, enter <tt class="code">http://example.com/index.html</tt> (replace <tt class="code">example.com</tt> with your websites address).
  and hit the <tt class="code">enter</tt> key.</li>
  <li>Click on a few links on your sites pages.</li>
  <li>Close your browser and bring up the JMeter window.</li>
</ol><p>
Expand the <tt class="code">Thread Group</tt> and there should be several samplers. At this point, the test plan can
be saved as is.
<p>
<table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
<tr><td>If you forget to add default HTTP Request settings, you will have to manually
delete the server name, and port.</td></tr>
</table>
</p>

</p><table border="0" cellspacing="0" cellpadding="0"><tr><td><img width='258' height='194' src="../../docs/images/screenshots/example-recording.png"/><br>
<font size="-1"></font></td></tr></table>
<p>
In this sample, there aren't any default request parameters. If a particular request parameter
is required by all pages, the request defaults is where one would add the entries.
</p><ol>
  <li>Select <tt class="code">Thread Group</tt> and change a few defaults:
    <dl>
      <dt><tt class="code">Number of Threads</tt></dt><dd>enter <tt class="code">5</tt></dd>
      <dt><tt class="code">Ramp-Up Period</tt></dt><dd>do not change</dd>
      <dt><tt class="code">Loop Count</tt></dt><dd>enter <tt class="code">100</tt></dd>
    </dl>
    <table border="0" cellspacing="0" cellpadding="0"><tr><td><img width='357' height='288' src="../../docs/images/screenshots/example-thread-group.png"/><br>
<font size="-1"></font></td></tr></table>

  </li>
</ol></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="validate-script"><strong>27.5 Validate the script</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Now we need to validate the script before to run our test plan. Save the test plan.
</p><p>
Right click on the <tt class="code">Thread Group</tt>
   <span class="menuchoice">
 <span class="guimenuitem">Validate</span>  </span>

  <table border="0" cellspacing="0" cellpadding="0"><tr><td><img  src="../../docs/images/screenshots/Validate-Test-Plan.png"/><br>
<font size="-1"></font></td></tr></table>

</p><p>
Check with <tt class="code">View Results Tree</tt> element if all is ok.
</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="correlate-start"><strong>27.6 Variabilize and Correlate the script</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
In some scripts, we will need to:
<ul>
  <li>Variabilize some input (login, password, search words...)</li>
  <li>Correlate some data (session variable...) between two requests</li>
</ul>  
</p><p>
To variabilize, we can use:
<ul>
	<li><tt class="code">CSV Data Set Config</tt> to get input data from csv file</li>
	<li>JMeter functions like <tt class="code">__counter</tt>, <tt class="code">__time</tt>...</li>
	<li>etc.</li>
</ul>
</p><p>
To correlate, we can get data from a request with <tt class="code">Post Processors</tt> like <tt class="code">JSON Extractor</tt>, <tt class="code">Regular Expression Extractor</tt>... and inject it in another request.
</p><p>
To find data to correlate, the easiest way to do it is to use the Search function in <tt class="code">View Results Tree</tt>.
<table border="0" cellspacing="0" cellpadding="0"><tr><td><img  src="../../docs/images/screenshots/Search-Correlation.png"/><br>
<font size="-1"></font></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="test-start"><strong>27.7 Start the test</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
At this point, we are ready to run our test plan and see what happens. When you're
ready to run the test, there are two ways:
<ol>
  <li>With the gui, but it's not recommended to big load test.</li>
  <li>With the command line.</li>
</ol>
</p><p>
Solution 1, with the gui, but just during debug phase, use Non GUI for your load test.
</p><p>
   <span class="menuchoice">
 <span class="guimenuitem">Run</span>&nbsp;&rarr;&nbsp;<span class="guimenuitem">Start</span>  </span>

or use the keyboard and press <span class="keycombo"><span class="keysym">Ctrl</span>&nbsp;+&nbsp;<span class="keysym">R</span></span>
</p><p>
  Before you start the test,  add a <tt class="code">Summary Report</tt> element and select it. As the test runs, the statistics will change
  until the test is done. At the end of the test, the summary report should look like this.
  <table border="0" cellspacing="0" cellpadding="0"><tr><td><img width='984' height='220' src="../../docs/images/screenshots/example-summary-report.png"/><br>
<font size="-1"></font></td></tr></table>

</p><p>
  While the test is running, in the upper right-hand corner, there should be a green circle. When the test is done, the circle should be grey.
  <table border="0" cellspacing="0" cellpadding="0"><tr><td><img width='132' height='39' src="../../docs/images/screenshots/example-running.png"/><br>
<font size="-1"></font></td></tr></table>

</p><p>
Solution 2, in command line, use <tt class="code">jmeter -n -t [jmx file] -l [results file] -e -o [Path to output folder]</tt>
</p><p>
At the end of the test, an HTML report will be generated and available in [Path to output folder] used in command line.
</p></blockquote>
</td></tr>
<tr><td><br></td></tr>
</table>
</blockquote>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<br>
<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="junitsampler_tutorial.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Next</font></a></div>
</td>
<td bgcolor="#525D76">
<div align="right"><a href="jmeter_distributed_testing_step_by_step.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Prev</font></a></div>
</td>
</tr>
</table>
</td>
</tr>
<tr><td>
<hr noshade size="1"/>
</td></tr>
<tr>
<td>
<table width=100%>
<tr>
<td>
<font color="#525D76" size="-1"><em>
Copyright &copy; 1999-2017, Apache Software Foundation
</em></font>
</td>
<td align="right">
<font color="#525D76" size="-1"><em>
$Id$
</em></font>
</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>
</td>
</tr>
</table>
</body>
</html>
<!-- end the processing -->