How to use Selenium webdriver with JMeter
To use Selenium Webdriver with JMeter, simply install "Webdriver Set" plugins. The WebDriver sampler is super useful if you want to test for performance AJAX, GWT based web applications and simulated user actions.
Steps to install Webdriver Plugin
- Download the plugins manager from https://jmeter-plugins.org/install/Install/
- Place plugins-manager.jar at the lib/ext/ folder.
- Open Jmeter, go to 'Options', then 'plugins manager'.
- Select 'Selenium/webdriver' support.
To verify correct installation, open JMeter and test if there is "[email protected] - Firefox Driver Config" under 'Config Elements'.
How to use Webdriver plugin ?
The webdriver isn't meant to create large scale load, but to get real browser timings while using the standard HTTP samplers to create the majority of the load simultaneously.
The webdriver sampler runs a physical browser on the load engine which consumes a significant amount of resources.
1. Add "Thread Group" to your "Test Plan".
Add the default thread group and keep the user count to 1.
2. Add Webdriver config element.
3. Open the "Web Driver Sampler" and add this code.
4.Run test and observe the results.
You should see the new Firefox window which will open the website. Search for “BlazeMeter”. After the test is has started running, open “View Results Tree” to confirm that there are no errors during the test run. If the “Response Code” is ‘200’ and the “Response Message” is ‘OK’ then the test was run successfully. If not, check the WebDriver script for errors.
Start the Test Run on BlazeMeter
To launch the WebDriver sampler test in the cloud with more concurrent users on BlazeMeter, create a new test and upload your JMX file to run it. In BlazeMeter you can use two available browsers - Firefox or Chrome.
- Firefox - Doesn't require any additional configuration. if it ran locally in JMeter, it will work in BlazeMeter.
- Chrome - You will require to add a path to the Chrome Driver in your in the scripts chrome driver configuration. the path is: /usr/sbin/chromedriverFurthermore, in BlazeMeter's test configuration page, please use JMeter version '2.11 BlazeMeter' and run in any cloud location which is not the 'sandbox' location.
Note: Before uploading your JMeter script remove/disable "View Results Tree" as it slows test performance.
When using the WebDriver plugin, in order to perform better load testing, assemble the Selenium tests with JMeter tests. The number of WebDriver samplers should be less than the number of JMeter samplers. If you need to get any values from websites through Ajax you can use WebDriver with the Once Only Controller in order to avoid continual/duplicate browser launches.
Use a Multi Test configuration where one test is a JMeter only test creating 99% of the traffic and the other test is dedicated for running WebDriver with a minimal amount of threads.
Want to learn more? Read our blog post, 6 Easy Steps to Testing Your Chrome Extension With Selenium