Run Selenium Script using JMeter – Step by Step Guide
In continuation of JMeter tutorial, we bring one of interesting step by step guide which helps you in Selenium JMETER integration. This article help you to perform load testing with Selenium JMeter. You may put desired load on your web application and measure performance of Application. In this tutorial, we will learn how to write selenium Junit test, create executable Jar and configure in JMeter to perform test.
Performance Testing is the one of important testing for every application which gives idea about application performance on various loads (users). This is essential especially when huge load is expected on our application due big sale or events. In performance testing, we may get one scenario where we need to perform load testing with Selenium JMeter. This may be bit tricky if you are not aware with JMeter features. But this tutorial end to end helps you in writing Selenium Test and Selenium Integration with JMeter.
Before proceeding with actual configuration following pre requisite should be done:
- Java should be installed ( if not then click here for Java installation steps)
- JMeter binaries file should be downloaded and unzipped ( if not then click here for JMeter step guide)
Steps to execute Selenium Test with JMeter
Step 1: Download Selenium Server Jar and Place on your local Machine:
Click Here to download – Selenium-server-standalone-3.14.159.jar
Step 2: Download JUnit4 Jar and save on our local machine.
Click here to download Junit Jar
Step 3: Download Hmcrestjar and save on your local machine
Click here to download hmcrestlibrary
Step 4: Open your Eclipse IDE, create one Java Project, Right click > Build Path and Add externals Jars
Step 5: Write Selenium Test – Create one Java class and write Selenium Test (want code explanation and basic steps –( Refer this tutorial)
Step 6: Convert Selenium Test in Executable Jar
Step 6 i: To create JAR of Selenium Test – Right click on Project and click on export
Step 6 ii: Go to Java section and select JAR file as per below snapshot:
Step 6 iii: Choose Project, class Path, project file, click on check box – Export generated class files, resources and give path to save jar File. Refer below snapshot for more details:
Step 7: Place Selenium Test Jar into junit directory. Refer below snapshot for more details:
Step 8: Place Selenium Server Jar into JMeter lib folder:
Step 9: Launch JMeter, go to “File” and create “New Test Plan”
Step 10: Click on JMeter Test plan and add Thread Group – Give Number of Users, Ramp –Up Period and Loop Count:
Step 11: Add “Junit Request” Sampler -Right click on Thread Group, Select, Navigate to Sampler and choose “JUnit Request”. Refer below snapshot:
Step 12: Add Selenium Testing in JUni Request
- Navigate to Junit Request
- Click on checkbox “Search for Junit 4 annotation (instead of Unit 3)
- Go to Classname and choose your Selenium Test Clas from dropdown
- Go to Test method and Choose MethodName from Dropdown
Refer below for more details
Step 13: Add Listeners to view Results: Right Click on JMeter Thread Group and click on “Add”, “Listeners” and suitable report plugin “View Result Tree” to get execution result status:
Step 14: Run JMeter Test plan and Validate Results: Go to View Result Tree window and click on “JUnit Request” and take performance Testing metrics:
Response Code and,
Great, you have successfully executed Selenium Test with JMeter. Hope this tutorial helped you. Still if you face any issue then feel free to reach out to us on info@thoughtCoders.com or call at +919555902032. To learn more about JMeter and other automation technologies explore our blog section.
ThoughtCoders is well known QA Services, Automation, DevOps and Testing Solution provider. Feel free to contact us on +919555902032 for free consultation.