Jmeter Selinium webdriver - UI load testing, result analysis - jmeter

I am doing UI load testing using distributed Jmeter Selinium webdriver
I have successfully execute the script and obtain the result.
Even though i have obtained the result with success status of 200 code, But how to confirm that all threads has successfully loaded the web pages including images and thumbnails
is there any assertion to very this or any suggestion pls

Unless there is a error in your script you will always get 200 as the status code. You could use WDS.sampleResult shorthand to set whether it is successful or not conditionally basing on your acceptance criteria
If you need to verify presence of a certain element or it's being displayed you could use WDS.browser.findElement() function and check whether it is displayed
You can also take a screenshot and compare it to the reference one using i.e. OpenCV Java bindings from JSR223 Assertion with Groovy as the language
WebDriver sampler returns the page source code as the response so you can also use Size Assertion to check if the response size is equal or larger than the anticipated one or Response Assertion to check if certain text is present or not
And last but not the lease using real browsers for performance testing is not recommended either by Selenium project or by WebDriver sampler developers
Performance testing using Selenium and WebDriver is generally not advised. Not because it is incapable, but because it is not optimised for the job and you are unlikely to get good results.
Note: It is NOT the intention of this project to replace the HTTP Samplers included in JMeter. Rather it is meant to compliment them by measuring the end user load time.
So I would rather recommend reconsidering your approach and create the main load using JMeter's HTTP Request samplers and use WebDriver Sampler for checking client side metrics like rendering time or JavaScript execution time.

Related

alternate option for window object in jmeter

When we try to encrypt and decrypt the application for front end request and response data,
Window object is not getting support in Jmeter.
As it generate 2 session id .
Kindly let us know any method in Groovy to support .
Window object is specific to the browser
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).
So there is no equivalent in any language supported by JMeter's JSR223 Test Elements
The options are in:
Use WebDriver Sampler for getting the session IDs you're looking for, they can be passed later on to "normal" HTTP Request samplers (but this way each JMeter virtual user will kick off a real browser instance)
Extract the code responsible for request encryption and session ID generation using browser developer tools and convert it to something JMeter could execute (remove the browser context), preferably in Groovy as it's the most performing scripting option

End to end page rendering time for performance test jmeter

My requirement is Overall response time, end to end time including rendering of page in browser should be 3sec . I have to execute Load test for 200 users. So in this case, the response time displayed in JMeter wont be end to end response time right. So during Load test execution , if i execute selenium functional automation scrip during 200 user load test ,whatever time we capture in selenium will that be end to end response time including rendering time? Or JMeter load test response time will be end to end response time?
Can someone please guide me if this is the right way?
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).
So JMeter's response time is the time to get the last byte of the response from the server, it doesn't "render" the page at all so if you're looking for that metric as well - stick to Selenium tests (you might want to use i.e. Navigation Timing API to know what exact rendering time is)
JMeter can be integrated with Selenium via WebDriver Sampler

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

Modify the resource path for a sub-sample in JMeter

I have recorded a user journey in JMeter (using AngularJS). When I click a link that spawns a GET request to a page, in-turn it spawns additional sub-requests to some page resources (images).
In Short:
Test Plan
-- Thread Group
---- Transaction Controller
------ HTTP Request (Main sample)
Here the main sample triggers additional sub-samples for resources and they fail due to path issues however this works manually using a browser.
I am in need to change the path of the sub-samples or not fail on a 404 for these sub-samples.
The fact you are getting different results in browser and JMeter indicates that your JMeter test is not well-behaved as it doesn't replicate browser requests with 100% accuracy therefore your load test doesn't make a lot of sense as "good" load tests must represent real user sitting behind real browser as close as possible. I would recommend comparing requests which are being sent from browser and JMeter with a sniffer tool like Fiddler or Wireshark, identify the differences and amend JMeter configuration so JMeter-driven requests would be exact replica of browser-driven ones (apart from dynamic parameters)
For the time being I can tell you only how to convert failed sub-samples into successful ones.
Add JSR223 PostProcessor as a child of your main request
Put the following code into "Script" area:
prev.getSubResults().each {
it.setSuccessful(true)
}
That's it, the above Groovy code will mark all sub-samples as successful no matter of original status (the response status code, message, body, etc. will remain original, JMeter just won't consider them as failed anymore). See Apache Groovy - Why and How You Should Use It article to learn more about using Groovy scripting in JMeter tests.

Resources