In this blog, we are going to discuss How to execute Selenium script in JMeter. Basically JMeter was developed to provide open source performance and load testing solution. Initially, JMeter was designed for testing web applications. Later it expands to other test functions. We can also perform functional testing using JMeter.
Why it is needed:-
In the current scenario, we are using much-advanced technology such that HTML5, JS, improved CSS. With these technologies, we are pushing more and more logic to the client itself. These advance improvements impact overall browser experience and execution time. Below are some of the examples:-
2. CSS Transormations(Various animations, 3D Matrix transformation),
3. Third party plugins(site analytics, various click based adds).
These mentioned logic ads the overall performance of the website/web app. But when we are talking about the JMeter matrix for these elements then it is not available in JMeter.
JMeter is not the real browser. So, we can’t measure the real-time user experience at the client-side. These advanced elements/logic need various rendering tie and effect in a real browser and give load time accordingly.
- First requirement for this setup is to have JMeter installed in the sysytem.
- Then install the “Selenium/webdriver” plugin using the JMeter plugin manager.
- gecko driver/chrome driver binaries downloaded in the system.
- Set system property for gecko/chrome driver in JMeter Installation folder.
How to set System property for chrome/gecko driver:-
- First go to JMeter installation folder.
- Then go to “bin/system.propertis” file
- Now set the system path for gecko/chrome driver as follows: (webdriver.chrome.driver=/home/knoldus/Downloads/apache-jmeter-4.0/bin/chromedriver), (webdriver.gecko.driver=/home/knoldus/Downloads/apache-jmeter-4.0/bin/geckodriver)
Steps to create sample JMeter project to run selenium script:-
- Launch JMeter GUI
- Now add simple Thread Group.
- Insert Firefox/chrome driver config.
- Then add web driver sampler to the thread group.
- Finally add ‘view results in table’ listner.
First selenium script in JMeter:-
WDS.log.info("Sample ended - navigated to http://google.com/");
Performance testing is not only about plain text response in some given specified time frame. When we are talking about performance testing then real-time page rendering should be one of the prime concerns. Because at the end of the day it the end-user who is going to use that website on a real browser. So, we must know How to execute Selenium script in JMeter to achieve this.