POP-UP Recording Limitation in Jmeter

There are generally three kinds of popup-1. Alert box 2. Confirm 3. Prompt. These are Client side scripts/programs generated in the webpage. Since Jmeter is build to load test Servers it can’t record these popups generated during recording a site with Jmeter.

The limitation has also been cited in http://jakarta.apache.org/jmeter/

These are the supported reasons for this:

1. JMeter is not a browser: JMeter is not a browser. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it’s possible to view the response as HTML etc, but the timings are not included in any samples, and only one sample in one thread is ever viewed at a time).

2. The Proxy Server can only record HTTP traffic (any requests to server)

3. Does JMeter process dynamic pages (e.g. Javascript and applets)

JMeter does not process Javascript or applets embedded in HTML pages. JMeter can download the relevant resources (some embedded resources are downloaded automatically if the correct options are set), but it does not process the HTML and execute any Javascript functions.

If the page uses Javascript to build up a URL or submit a form, you can use the Proxy Recording facility to create the necessary sampler. If this is not possible, then manual inspection of the code may be needed to determine what the Javascript is doing.

I have tried verifying this with two methods. In first method I recorded the pop-ups in BADBOY tool and tried to export it to Jmeter. Secondly tried it with Jmeter itself.

Method1: (Exporting from BADBOY)

We record the Alert box and prompt from the below link: http://alokranjan.freehostia.com/pop/popup.htmlpop1

Now we save the script. And when we try to export it the following error comes.

pop2

It says items like Messagebox and alert box are not supported in Jmeter.

pop3

Method2. (Recording in Jmeter)

Site: http://alokranjan.freehostia.com/pop/popup.html

pop4

When we click on the write sth alert box it writes a line (this is a sample line) on the web page.

When we record the site only the page gets recorded and .The alert box and text output doesn’t get recorded.

pop5

This confirms that Jmeter can’t handle popups or client side scripts.

Custom Plugins for Jmeter

1. Load Testing RMI server in Jmeter : (New RMI sampler)

2. Better Graphs in Jmeter : (Custom Listener)

3. Enhanced JDBC Sampler for Jmeter

4.Maven JMeter plugin and report generation

4. SMTP Sampler Plugin in Jmeter

5.Testing EJBs with JMeter

6.JMeter Aggregator Plugin

7. Record and playing back RMI calls (RMI Serevr) – Swing Sampler in Jmeter

8.JMeter-groovy-sampler – Runs Groovy Scripts in Jmeter

9. Automate JMeter tests in Maven

10. JMeter to Nagios

Generate the test report in Jmeter

Prerequisites:

1. ‘Apache-ant’ is the Pre-requisite for generating the report from the jmx file. Apache Ant is a Java-based build tool.
2. Ant-jmeter.jar

Steps:

1. Create a new variable JAVA_HOME in the environment variable and set the path for the jdk.
2. You can find the Environment variable by right clicking on the computer Icon then properties-> Advance-> environment variable. Then click on the new and give the variable name as well as path also.
3. Likewise create another variable ANT_HOME and set the path for the Apache-ant.
4. Create another variable PATH and set the path for apache-ant up to bin folder as shown in the fig. bellow.
testreport1

5. Place the ant-jmeter.jar file in side ‘Extras’ folder. Which is located in the path jakarta-jmeter-2.3.2->extras
6. Navigate to the ‘build.xml’ folder of the jmeter which is located in the path jakarta-jmeter-2.3.2->extras->build.xml.
7. Set the classpathref = “d:/jakarta-jmeter-2.3.2/extras/ant-jmeter.jar “
8. Set jmeterhome=”D:/jakarta-jmeter-2.3.2″
9. Set style=”D:/jakarta-jmeter-2.3.2/jmeter-results-detail-report${style_version}.xsl” and save it.
10. Now copy your jmx file and the build.xml file put it in a folder where ever you want to generate the report.
11. Open your command prompt and navigate to the folder where your jmx and build file is located.
12. To run a test and create the output report:
Type the command “ant -Dtest=script”(for eg. I have my test.jms file and the command is ant-Dtest=test)
It will generate an Html file. This can be open in the browser as shown in the fig. bellow.
testreport2

13. To run a test only:
Type the command “ant -Dtest=script run”
14. To run report on existing test output
Type the command “ant -Dtest=script report”

Getting Memory usage of a server in Jmeter

Steps:-

1. The first step is to add a Thread Group element.

The Thread Group tells JMeter the number of threads you want. Always use 1, since we are using JMeter as a monitor. This is very important for those not familiar with server monitors. As a general rule, using multiple threads for a single server is bad and can create significant stress.

Change the loop count to forever (or some large number) so that enough samples are generated.

2. Add the HTTP Authorization Manager to the Thread Group element (Add –> Config element –> HTTP Authorization Manager). Enter the username and password for your webserver. Important note: the monitor only works with Tomcat5 build 5.0.19 and newer.

1.       leave the base URL blank

2.       enter the username

3.       enter the password

3. Add the HTTP Request to the Thread Group element (Add –> Sampler –> HTTP Request). Then, select the HTTP Request element in the tree and edit the following properties):

1.       Change the Name field to “Server Status”.

2.       Enter the IP address or Hostname

3.       Enter the port number

4.       Set the Path field to “/manager/status” if you’re using Tomcat.

5.       Add a request parameter named “XML” in uppercase. Give it a value of “true” in lowercase.

6.       Check “Use as Monitor” at the bottom of the sampler

4. Add a Constant timer to this thread group (Add –> Timer –> Constant Timer). Enter 5000 milliseconds in the “Thread Delay” box. In general, using intervals shorter than 5 seconds will add stress to your server. Find out what is an acceptable interval before you deploy the monitor in your production environment.

5. Add the Monitor Results Listener by selecting the test plan element (Add –> Listener — > Monitor Results). There are two tabs in the monitor results listener. The first is the “Health”, which displays the status of the last sample the monitor received. The second tab is “Performance”, which shows a historical view of the server’s performance.

6. Run the test and see the result in view listener tree.

The free memory and total memory is in response data for that sample.

Note: If you run out of memory

Negative-effect of Jmeter is they consume a lot of memory. If your JVM is running out of heap memory, you need to edit your Jmeter.bat and increase the heap memory size by editing the following line:

>> HEAP=”-Xms256m -Xmx1024m”

Change the jmeter.bat HEAP=-Xms1024m -Xmx1024m

If you have a system RAM of 2GB then edit jmeter.bat to increase heap memory size “Xms1536m-xmx1536m”.

XML

What is XML

  • XML stands for EXtensible Markup Language
  • XML is a markup language much like HTML
  • XML was designed to carry data, not to display data
  • XML tags are not predefined. You must define your own tags

XML is hierarchical, and as such the proper nesting of tag elements is crucial.

Example:

<?xml version=”1.0″?>
<MovieCatalog>
<movie>
<title>The Matrix</title>
<actors>
<actor>Keanu Reeves</actor>
<actor>Laurence Fishburne</actor>
</actors>
<director>Wachowski Brothers</director>
</movie>
</MovieCatalog>

Well Formed XML Documents:

A “Well Formed” XML document has correct XML syntax.The syntax rules are:

  • XML documents must have a root element
  • XML elements must have a closing tag
  • XML tags are case sensitive
  • XML elements must be properly nested
  • XML attribute values must be quoted

Valid XML Documents

A “Valid” XML document is a “Well Formed” XML document, which also conforms to the rules of a Document Type Definition (DTD).

The purpose of a DTD is to define the structure of an XML document. It defines the structure with a list of legal elements:

DTD for the above xml :

<!DOCTYPE MovieCatalog [
<!ELEMENT MovieCatalog (movie,title,actors+,director)>
<!ELEMENT actors(actor)>
<!ELEMENT movie (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT actors (#PCDATA)>
<!ELEMENT actor (#PCDATA)>
<!ELEMENT director (#PCDATA)>
]>

an XML based alternative to DTD called XML Schema can also be used.

Jmeter Tutorials

Following are some good tutorials on Jmeter

1. Your First Jmeter Test

2.Regression Testing With JMeter

3. JMeter FAQ

4.Load Testing your Applications with Apache JMeter

5. Load Testing with Apache JMeter