You have probably used Jmeter on some of your previous projects, in this blog I take a dig at using Jmeter for functional and performance testing a WCS store. It is a powerful tool and supports advanced features like pre, post processing of request/response data using BSL shell script, you can use your existing java skill sets to write these processors.
We will look at how Jmeter can be used to record a specific use case in WCS store for performing functional/performance tests.
Step 1: Add HTTP Proxy Server Element for recording script, follow steps as shown in the screenshot below
Step 2: In the previous step we have enabled Jmeter Http Proxy to run on localhost port 8080, now we need to modify the browser proxy setting to tunnel all traffic through this proxy. following screenshot is an example from FF browser
Step 3: Before we record scripts we need to set few exclusion and inclusion rules on Jmeter http proxy, the example below excludes static assets like JS, images and html pages, you can modfy this setting based on your testing needs, fow now following rules are sufficient for testing dynamic WCS Pages.
Create a new Test Plan as shown in the screen shot below, I have named this thread group as "User Login".
Step 4: Launch your browser and browse through the site to record following steps
View Madison's Home Page
Click on Sign in link
Sign in with username/password
You should be now able to see recorded scripts under "Test Plan", as you can see in the screenshot below It has captured Dynamic URL's for my Use Case.
Step 5: WCS sets quite a few cookies which are used to identify a logged in or guest session, Jmeter supports "Http Cookie Manager" config element, this can be used to ensure cookie values are passed in every consecutive requests, add the "Http Cookie Manager" config element as follows
Step 6: Now that the script is recorded we would like to feed in few dynamic value from an external data feed file, for instance in this case I would like to feed in a set of test username/password which should be used by my test script, to achieve this we need to add "CSV Data Config" element as shown in the screenshot below.
Make sure you place the seed data file under the Jmeter installation folder, in the sample below I have created a folder seed_data under my Jmeter installation folder.
The seed data consists of following, the first row indicates the variable names and next set of rows indicate values in them, for every iteration of the thread Jmeter will read consecutive row of data and automatically convert them to Jmeter variable ${username} and ${password}
username,password
user1,user1password
user2,user2password
user3,user3password
Modify the recorded step .../servlet/logon and replace the username/password that was used during recording with Jmeter variables ${username} and ${password} as shown in the screen shot below
When you execute the script Jmeter will dynamically feed username/password from your external feed file to the script, this way we can perform a test which replicates multiple user logging into the site
Step 7: How do we know that we are getting expected results from the script execution? Jmeter has post-processor element which can be used to script code that can look for specific values in the response HTML page, this can be used for functional testing of pages.
When you login from browser we are displayed a welcome message in the post login page as shown in the screen shot below, we will use this text check rule in the post processor script
Add "Response Assertion" element to your test step and make sure you make selections as shown in the screenshot below, the pattern check in this case checks for Welcome, <username>
Step 8: Start the test by clicking on start button, you should be able to see the assertion results under "View"
We will look at how Jmeter can be used to record a specific use case in WCS store for performing functional/performance tests.
Step 1: Add HTTP Proxy Server Element for recording script, follow steps as shown in the screenshot below
Click on "Start" button to run the Proxy on port 8080
Step 3: Before we record scripts we need to set few exclusion and inclusion rules on Jmeter http proxy, the example below excludes static assets like JS, images and html pages, you can modfy this setting based on your testing needs, fow now following rules are sufficient for testing dynamic WCS Pages.
.*\.jpg |
.*\.js |
.*\.png |
.*\.gif |
.*\.swf |
.*\.css |
Create a new Test Plan as shown in the screen shot below, I have named this thread group as "User Login".
Step 4: Launch your browser and browse through the site to record following steps
View Madison's Home Page
Click on Sign in link
Sign in with username/password
You should be now able to see recorded scripts under "Test Plan", as you can see in the screenshot below It has captured Dynamic URL's for my Use Case.
Step 5: WCS sets quite a few cookies which are used to identify a logged in or guest session, Jmeter supports "Http Cookie Manager" config element, this can be used to ensure cookie values are passed in every consecutive requests, add the "Http Cookie Manager" config element as follows
Make sure clear cookie setting is selected, this will ensure every new iteration of the test will clear all cookies before executing any steps in the test.
Step 6: Now that the script is recorded we would like to feed in few dynamic value from an external data feed file, for instance in this case I would like to feed in a set of test username/password which should be used by my test script, to achieve this we need to add "CSV Data Config" element as shown in the screenshot below.
Make sure you place the seed data file under the Jmeter installation folder, in the sample below I have created a folder seed_data under my Jmeter installation folder.
The seed data consists of following, the first row indicates the variable names and next set of rows indicate values in them, for every iteration of the thread Jmeter will read consecutive row of data and automatically convert them to Jmeter variable ${username} and ${password}
username,password
user1,user1password
user2,user2password
user3,user3password
Modify the recorded step .../servlet/logon and replace the username/password that was used during recording with Jmeter variables ${username} and ${password} as shown in the screen shot below
When you execute the script Jmeter will dynamically feed username/password from your external feed file to the script, this way we can perform a test which replicates multiple user logging into the site
Step 7: How do we know that we are getting expected results from the script execution? Jmeter has post-processor element which can be used to script code that can look for specific values in the response HTML page, this can be used for functional testing of pages.
When you login from browser we are displayed a welcome message in the post login page as shown in the screen shot below, we will use this text check rule in the post processor script
Add "Response Assertion" element to your test step and make sure you make selections as shown in the screenshot below, the pattern check in this case checks for Welcome, <username>
Step 8: Start the test by clicking on start button, you should be able to see the assertion results under "View"
As you can see in the screenshot when ever login fails the post processor can not find the welcome message and hence the test step will be marked as failed.
As you can see Jmeter provides a very simple yet a powerful set of features which can be used for automation of functional test and can be used for performance testing as well, more to come in my future blogs on some of the more advanced features of Jmeter which can be used in the context of WCS testing.
For more reading read through the official documentation available on http://jmeter.apache.org/
There were some updates in HTTP Proxy Server in Jmeter 2.9(lates release).
ReplyDeleteThey have added "Add suggested Excludes" button to "URL Patterns to Exclude" table. This allow populating exclude patterns from jmeter.properties(by default - "proxy.excludes.suggested=.*\.js;.*\.css;.*\.swf;.*\.gif;.*\.png;.*\.jpg;.*\.bmp").
Some other updates described in JMeter 2.9: what's new? article
I also used the above proxy settings in firefox but still getting the same error. I am using JMeter 2.9 1437961 version.
ReplyDeleteTried on jmeter 2.10 and was able to set proxy, are you sure the proxy is able to run on 8080, may be it is used by another application, try changing the port and see if it works.
ReplyDeleteCan you share a sample Jmeter script? It would make it much quicker than starting from scratch. :-)
ReplyDeleteAbsolutely fantastic posting! Lots of useful information and inspiration, both of which we all need!Relay appreciate your work.
ReplyDeleteSoftware Testing Services
Functional Testing Services
Test Automation Services
QA Automation Testing Services
Regression Testing Services
API Testing Services
Compatibility Testing Services
Performance Testing Services
Security Testing Services
Vulnerability Testing Services
you have written an excellent blog.. keep sharing your knowledge...
ReplyDeleteJMeter Training in Chennai
Go Lang Training in Chennai
Wonderful post and more informative!keep sharing Like this!
ReplyDeletePHP Training in Bangalore
php classes in pune
php training in hyderabad
PHP Training in Gurgaon
php training in delhi
This post is so interactive and informative.keep updating more information...
ReplyDeleteGraphic Design Courses in Mumbai
Graphic Designing in Ahmedabad
Graphic Design Courses in Kochi
Graphic Design Courses in Trivandrum
Graphic Design Courses in Kolkata
Good to see such a nice blog post Best Software quality assurance services in USA
ReplyDeleteI really enjoyed learning about this in such an engaging way. There's obviously a lot of enthusiasm for the subject which comes through clearly. Some imaginative ideas presented. Will be interesting to see if any influence changes over time. In any case, very unique perspective offered here clear tarpaulin. Thanks for the original read!
ReplyDeleteThought-provoking as always from you. Always appreciate your no-nonsense analyses of current topics. Enjoyed getting your perspective on this. Some sharp observations that gave me a new lens through which to view it.
ReplyDeleteblack tarpaulin