steps for recording the selenium events on jmeter proxy - selenium

I am presently working on a project for which selenium scripts are prepared and i want my jmeter proxy should record the steps executed by selenium browser. I tried running selenium and jmeter proxy server on same port but while doing that proxy server of jmeter refuse to start on same port. I read somewhere that this is possible but i am not getting the steps needs to follow.

You should do the same what you will do for simple test recording through Jmeter proxy:
setup Jmeter HTTP Proxy Server;
start configured Jmeter Proxy;
configure and enable proxy settings in your test browser (used by selenium) to use Jmeter Proxy.
Then run your selenium tests as usual, via configured test browser - HTTP Proxy Server will record execution.
To exclude all the steps performed in the "selenium-server" window try to add the following to 'URL Patterns to Exclude' in HTTP Proxy Server settings:
^/selenium-server/.*
Useful point here is to separate recorded execution into different Thread Groups - e.g. separate Thread Group in Jmeter for each recorded selenium testcase.
Step-by-step guideline you may found here.
To tell the truth such the "re-recording" may appear not very useful and effective: JMeter is not a browser, and does not interpret the JavaScript in downloaded pages.
As per Jmeter wiki:
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.
So if you need Jmeter possibilities to implement load/performance-testing based on existent Selenium functional scripts better for you then use run Selenium scripts from Jmeter.

Related

Recording scripts using HTTP Test Script Recording vs Blazemeter plugins

Just a simple question, which Jmeter recording method is better for the timebeing? Record script using HTTP Test Script Recording (using proxy) or Blazemeter plugins? Can provide justification for each?
Because at first I record with blazemeter plugins, when I tried to apply correlation, it never works. But then I try to record manual using proxy, my correlation works. I tried to correlate userSession in the webtours test application.
Mind if you can share your thoughts on that? In which scenario we have to choose scripting using Blazemeter plugins or proxy in Jmeter apps? Thanks!
Both basically intercept HTTP requests and convert them to JMeter's HTTP Request samplers
HTTP(S) Test Script Recorder requires extra steps like importing certificates, configuring proxy server, etc.
BlazeMeter Chrome Extension doesn't require any extra setup, however for certain POST requests it may add multipart/form-data where it's not needed
Going forward you can consider the following alternatives:
Correlations Recorder Plugin for JMeter - where you can add correlation rules beforehand and they will be automatically applied to the content substituting hard-coded values with the appropriate JMeter Variarbles, you will still have to perform correlation, but it will be one place only
BlazeMeter Proxy Recorder - which is capable of exporting recorded requests in "SmartJMX" mode with automatic detection and correlation of dynamic parameters (even including timestamps), but it requires Internet connectivity so if you're recording a local application you won't be able to use it.
If you're still interested in my "thoughts" I don't think that any "recording" solution can substitute a human, especially when it comes to more complex topics like simulation of AJAX requests so I would recommend using a 3rd-party sniffer tool to compare the network footprint from the real browser with JMeter's and amend JMeter configuration so it would be 100% accuracy.

Unable to get fingerprint in browser using Apache JMeter

I performed performance testing using Apache JMeter version 3.X.
At one of the step, I'm not able to get the browser fingerprint value. I receive NULL value and it cause my program to be terminated.
But when I'm using normal browser, it works find.
Is there any limitation on Apache JMeter where it cannot get the browser fingerprint value?
First of be aware that it's recommended to use latest version of JMeter so consider upgrading to JMeter 5.2 (or whatever is the latest stable version available at JMeter Downloads page)
With regards to the "fingerprint" itself, according to the main page of JMeter project:
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 you need to investigate the logic of this "fingerprint" check, you can make JMeter to behave like a real browser up to certain extent like:
use HTTP Cookie Manager to represent browser cookies
use HTTP Header Manager to send at least User-Agent and other headers which normal browser sends
etc.
however if the "fingerprint" check relies on JavaScript you will need to re-implement the same JavaScript using JSR223 Test Elements
The main rule is: the network footprint of JMeter must be exactly the same as network footprint of the real browser (apart from dynamic values which need to be correlated), if you will send proper requests using JMeter - your system under test will not see the difference.

How to run headless browser in jmeter for WebDriver Samplers,

Detailed steps please, tried to use both HTMLUnit Driver Config and PhantomJs config, but no luck
How to run headless browser in jmeter for WebDriver Samplers, detailed steps please, tried to use both HTMLUnit Driver Config and PhantomJs config, but no luck. My requirement is I need to convert selenium script into jmeter script, I have created Webdriver script in jmeter, I need to run it with 100 users, as I donot want to launch 100 instances of browser, I want to run it as headless browser, directly creating jmeter load script is not an option as request is using a dynamic valuse which is not available in server response.
You will launch 100 instances of browser in any case, no matter whether browser is headless or not and most probably your JMeter system will not be able to handle that many browser instances and you will have to go for distributed testing
Your "no luck" statement doesn't make sense as information is not sufficient to come up with solution.
For HTMLUnit it is enough to add HtmlUnit Driver Config and WebDriver Sampler itself
For PhantomJS Driver Config you need to download PhantomJS binary and specify location under PhantomJS -> Path to PhantomJS executable input. Of course add WebDriver Sampler with your code
In both cases you will need to have Selenium client libraries somewhere in JMeter Classpath so make sure to install WebDriver Sampler using JMeter Plugins Manager - it will automatically take care of the dependencies.
If JMeter doesn't work as expected first of all check jmeter.log file for any suspicious entries - in 99% of cases it contains enough information to get to the bottom of the issue.
Also be aware that dynamic value is not a showstopper, in the absolute majority of cases it is somewhere in response (either in body, or in URL or in cookies, or in headers), in remaining cases it can be calculated or generated.

Where does Selenium store the DOM, if at all?

I'm trying to understand the performance impacts of things like WebDriver.findBy(...). For example if I was using Selenium to drive a local Chrome instance:
WebElement betty = webDriver.findBy(By.id("betty"));
Does the Selenium library
a) have the DOM within the JVM to evaluate?
b) go to the local Chrome driver binary to evaluate?
c) go to the browser instance to evaluate?
And does the answer change for a Grid situation?
I found a nice technical guide that explains this.
The browser driver uses an HTTP SERVER which waits continuously for
new Selenium commands.
It has the following purposes:
read HTTP requests coming from the client (client = computer that executes the test automation scripts)
determines the series of steps needed for implementing the Selenium command
sends the implementation steps to the browser
gets the execution status from the browser
send the execution status back to the client
For each Selenium command of the automation script, a http request with a specific path is created.
When the automation script is executed, the first http request generates a new session that is specific to the browser where the automation scripts run.
The session id will be used for the http requests that correspond to all other
Selenium commands from the automation script.

Jmeter recording in NON GUI mode for Selenium testing

I would like to record the network requests of a Selenium test. Rather than using jmeter GUI, I would like to automate this process in a script. The idea would be to run a selenium test and record it simultaneously. Is there a built in way to do this?
GUI Jmeter is ideally for development of scripts, which are then run headless to get true performance figures.
You can develop selenium webdriver tests as junit tests, which integrate to JMeter very easily.
Running a recorded Selenium IDE test would not be so straightforward, better to export it as Java Webdriver.
Make sure you follow junit naming conventions and annotations (depending which version you use). Write the test class, including junit 'test' methods, then create a jmeter test plan with a junit sampler, and configure the junit sampler to run your test method[s].
maven and plugins can be used to make it all run seamlessly in headless mode on any host.
Once you have developed one of these, it will be easy to review the jmx test script and automate the process of creating more jmeter tests, if that is what you meant by automating the process.
Start JMeter's Proxy Server
Configure your Selenium script to use JMeter as a proxy. See Using a Proxy guide for configuration details for each driver
Run Selenium test - all requests should be recorded by JMeter.
Add the next test elements to JMeter test plan:
HTTP Cookie Manager - to represent browser cookies
HTTP Cache Manager - to represent browser cache
follow recommendations from How to make JMeter behave more like a real browser to properly configure embedded resources retrieval, user agent, request defaults, etc.
Configure Thread Group parameters according to your load scenario.
Replay the test.
I expect that you will need to apply some correlation, but it may be not required.