JMeter - How do you group all requests related to a page to provide cleaner results? - jmeter

Im new to JMeter and have just created a test plan using the proxy server.
The test plan covers a fairly long user journey on a web app with a lot of pages, images, scripts and css being requested, because of this when I run the test plan and view the results in a listener such as the 'View Results Tree' the sampler list is very long and if I try and use a graph there are so many results its hard to make out individual values.
Is there a way in JMeter where I could group all the requests related to a page under that page and only have to page name display in the listener but still have the ability to drill into an individual page and see the details for each sample?
Thanks.

For this you can use Transaction Controller:
https://jmeter.apache.org/usermanual/component_reference.html#Transaction_Controller
Keep Include duration of timer and pre-post processors in generated sample unchecked.
If you're looking to learn jmeter correctly, this book will help you.

I agree with PMD, Transaction controller is exactly what you need.
You can achieve that automatically (while you're saving your test) if you enable jMeter proxy's option Put each group in a new transaction controller.
A couple of more details (about jMeter Plugins' listeners I regularly use) here:
Define a group of requests in order to obtain a total time in Jmeter

You can use the tool BADBOY tool to record your test and there you can easily bifurcate/ remove the unwanted content.
From BADBOY you can directly Export the recorded script to JMeter by simply from
File menu>>Exort To JMeter
This is what currently we are following and is a bit easy to use.

Related

Can JMeter do automation testing like Selenium can do?

i am still new to JMeter and i was assigned to a work that I will need to use JMeter to perform automation testing. The idea is to write script using JMeter and run the script to fill in the forms in the website. I was curious that can JMeter use different data from the database to fill in the form of the website everytime it execute?(unique data for every user)
I have followed this tutorial (https://www.blazemeter.com/blog/fill-forms-and-submit-with-jmeter-made-easy/ ) and it succeed, however, when i try to change the parameter name (to some other names that do not matches the field name found in the inpect mode), it still works. So i was wondering how JMeter knows where to put in the parameter even i have change to a wrong field name?
As per JMeter Project main page:
JMeter is not a browser, it works at protocol level. 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 displayed at a time).
Browsers don't do any magic, they execute HTTP Requests, wait for response and render it. JMeter in its turn can execute the same HTTP requests so traffic would be the same, however it will not render the response, but rather measure the time and collect some more metrics.
If you change the names of the inputs in the form most probably the request will be successful, to wit you will get HTTP Status Code below 400 hence JMeter will mark the result as "green", however if you inspect the response using View Results Tree listener you will see that the form is not filled and/or you still at the same page.
If you want to use JMeter for checking the data returned by the application you're testing consider using JMeter Assertions to test presence of expected values, absence of errors, set response time thresholds, etc.
You can automate the form submission or order placement usin JMeter. You can JMeter for API testing as well by adding assertions. But the main purpose of the JMeter is to test the performance of the application. Its not like selenium which performs actions on the browser whereas JMeter sends the request in various protocols to relevant server and can also simulate many users at the same time.
If you want to do extensive automation testing,JMeter isnt the ideal tool for that.
You can use webdriver sampler to run the selenium with jmeter. It requires to configure sampler and browser config which are plugin and can be downloaded using plugin manager.
For more info:-https://www.blazemeter.com/blog/jmeter-webdriver-sampler/
Now, without the plugin it is working on protocol level and not on the frontend as pointed out in the above comments.
So, yes it can depend on which layer you want to work. It can work on frontend like selenium using the webdriver plugin and can submit the form with different data as a direct request to the server without using the frontend/GUI.
Hope this helps.
It depends on what you are trying to automate. If you plan to automate API invocation where there are some pre-requisites like grabbing tokens, cookies, session IDs from the browser, then JMeter can probably be used where existing JMeter capabilities can be leveraged using BeanShell scripting and other plugins.
But if you plan to have a full blown UI automation framework then JMeter might not be an ideal choice.

Wait until option JMeter

I wanted to know if JMeter has a option where you wait until some element disappears.
Example a loading bar only once that has completed or no longer visible then to carry on. (Also being able to monitor the length of time taken)
I have through about writing it as a webdriver test and then running it as a Junit test in JMeter but wanted to know if there is a simpler solution.
Any ideas welcome :)
First of all you need to realize that JMeter is not a browser
JMeter is not a browser, it works at protocol level. 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 displayed at a time).
So JMeter doesn't execute any client-side JavaScript, the only way of implementing "wait until" option is using While Controller in order to re-execute the same request again and again until response data will contain (or stop containing) the element you're looking for.
If you need to evaluate client-side JavaScript the only option would be going for Selenium. I would recommend using WebDriver Sampler instead of going for JUnit as this way you won't have to recompile your script for any change, it will be inlined into .jmx
You can use Transaction Controller to monitor the time taken by the whole process and to wait for a change , have a look at this:
http://www.sourcepole.ch/2011/1/4/waiting-for-a-page-change-in-jmeter

How to use jmeter using ant task - load testing on Dot Net application

I have just tried jmeter examples using ant task. I got the HTML output. Now,
I built my application using c#.net,asp.net,javascript,jQuery,Ajax,Json etc.
This is the url http://localhost/test/pagemanager.aspx which shows my
LOGIN Screen. Once after login, the user can access over multiple menus(pages) to access like checking their personal data, overall student details like batch wise, registering a new student etc... My URL http://localhost/test/pagemanager.aspxremains constant at every time.
The site can be accessed by multiple users for multiple times. I needs to find a load testing. Can some one give me a configuration step to find load testng to my application.
Thanks in advance.
First of all I would recommend recording your test scenario steps starting from login via JMeter build-in HTTP(S) Test Script Recorder.
See JMeter Proxy Step by Step guide for detailed instructions.
Once you have recorded test flow you'll need to do some correlation as the nature of ASP.NET applications assumes mandatory dynamic parameters like VIEWSTATE. So you'll need to extract VIEWSTATE and similar from previous server response and add it to next request.
See ASP.NET Login Testing with JMeter for more details.

JMeter - link clicking to generate a username

Sorry if this has been answered already, i tried to search but could get the exact information i am after.
The issue:
I am using JMeter to run some tests on a web application, as part of one of the flow, I under a first and surname in 2 input fields and i have link (Get userid) on clicking on the link the system will generate a user name. The user name is made up of first 4 letters from surname and first letter from the firsname and number at the end example: firstname is Test and surname is Environment, on clicking the get user id link the username will be generated as 'envit1' if 'envit1' is already existing then it would generated 'envirt2'
How do I simulate the click which generates the userid using jMeter.
Apologies but I am fairly new with JMeter, please ask if you need more infomratmation.
Many thanks in advance, Kay
If you're new to JMeter the best way to get things done is recording your user ID generation steps using one of the following approaches:
JMeter bundled HTTP(S) Test Script Recorder which acts like a browser proxy
A Google Chrome Extension which is capable of recording JMeter .jmx scripts right from your browser.
You can see what requests are being sent and HTML responses using handy View Results Tree listener.
However if clicking on link isn't being recorded, it's being handled by client-side Javascript. JMeter is not a browser and isn't capable of executing Javascript so you'll have to use WebDriver Sampler as Releasematic suggests.
You can use WebDriver Sampler but in each iteration it opens browser which may increase RAM usage. There is another option is to generate user id by running JS code in "JSR223 Sampler". With JSR223 Sampler you can run JS code but can't get access to DOM, so such JS code won't work:
function () {document.getElementById("edit-buttons-cleanup").click();};
You can install the plugin pack for the JMeter WebDriver sampler. Then, using some Javascript commands, you can start either a Firefox or a headless HTMLUnit and operate upon a webpage in a Jmeter step.

jmeter regarding performance and load testing

Let me describe the issue which i have been facing.
i want to do performance and load testing on our internal website. which has login and other functionalities.
the issue i am facing that when i hit 12 or any number of request using http sampler then i am getting same response from all the 12 request. But actual scenario is that webpage displays different data for different page.
I checked using firebug and everything is working fine over there using correct response from request but when i use jmeter i am using same response from every request.
Please let me know if anybody had faced same kind of issue of is there anything i am doing wrong in configuring script.
Try to add HTTP Cookie Manager to your test-plan to the root (Test Plan) node or to the Thread Group node.
As per jmeter documentation:
The last element is a HTTP Cookie Manager. A Cookie Manager should be
added to all web tests - otherwise JMeter will ignore cookies. By
adding it at the Thread Group level, we ensure that all HTTP requests
will share the same cookies.
Ensure that parameters values that are dynamic are not hard-coded (after recording jmeter scripts, for example): no hard-coded JSessionID values in your HTTP requests, e.g..
Ensure you don't miss any necessary params in your HTTP requests.
JMeter does not process Javascript or applets embedded in HTML pages.
Your problem may be caused by this feature.
As per jmeter documentation:
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 would also recommend your to look first into Jmeter reference before further scripting activities - this may prevent from some faults and frustration.
At least these:
Building a Test Plan
Elements of a Test Plan
Building a Web Test Plan
Building an Advanced Web Test Plan
Hope this helps.
I would suggest - Use Jmeter's Regular Expressions. You may be able to resolve this issue with RegEx. Post using regex, use 'View Results Tree' listener to check if you are getting apt response for each of your threads.
You can also analyze your results using Blazemeter's listener that gives you more insights into your test.

Resources