Setp by step guide to run Selenium Script in JMeter

Measure Selenium Script Performance with JMeter

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.

Pre requisite:

Before proceeding with actual configuration following pre requisite should be done:

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

 

- Libraries required to run Selenium Test with Java

 

Step 4: Open your Eclipse IDE, create one Java Project, Right click > Build Path and Add externals Jars

Eclipse Window to Configure Build Path

 

Eclipse Window to Add External Jars (Libraries) in Project

Step 5: Write Selenium Test – Create one Java class and write Selenium Test (want code explanation and basic steps –( Refer this tutorial)

Eclipse Window to Verify Added Libraries

Selenium Code:

import org.junit.Assert;

import org.junit.Test;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class DemoTest {

                @Test

                public void ThoughtcodersSmoke() {

                                System.setProperty(“webdriver.chrome.driver”, “E:\\seleniumlib\\chromedriver.exe”);

                                WebDriver driver = new ChromeDriver();

                                driver.get(“https://thoughtcoders.com/”);

                                String title = driver.getTitle();

                                Assert.assertEquals(title, “ThoughtCoders | QA Services, Application Development and Training Solutions – thoughtcoders”);

                                driver.close();

                }

}Basic Selenium Test written with Junit

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

Eclipse Window to export Java Project as Jar

Step 6 ii: Go to Java section and select JAR file as per below snapshot:

Eclipse Export Wizard – Choose JAR file to export as JAR

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:

Eclipse Window to Save Jar file

Step 7: Place Selenium Test Jar into junit directory. Refer below snapshot for more details:

Add Selenium Test Jar in into JMeter Lib> junit folder

Place SeleniumTest Jar in JMeter JUnit library

Step 8: Place Selenium Server Jar into JMeter lib folder:

JMeter lib folder – Place Selenium Server JAR to trigger

Step 9: Launch JMeter, go to “File” and create “New Test Plan”

JMeter Window to 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:

JMeter Widow to Set Thread Group

Step 11:  Add “Junit Request” Sampler -Right click on Thread Group, Select, Navigate to Sampler and choose “JUnit Request”. Refer below snapshot:

JUnit window to add “JUnit Request

Step 12:  Add Selenium Testing in JUni Request

  1. Navigate to Junit Request
  2. Click on checkbox “Search for Junit 4 annotation (instead of Unit 3)
  • Go to Classname and choose your Selenium Test Clas from dropdown
  1. Go to Test method and Choose MethodName from Dropdown

Refer below for more details

Junit Request Window- Add Selenium Test in JMeter

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:

JMeter Window to Add Listeners

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:

Load Time

Start Time

Response Code and,

Response Message

View Result Tree – Validate Selenium Test Results

 

 

 

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.

Write A Comment