Selenium Webdriver Performance testing with Jmeter and Selenium Grid


In this post, we will complete Selenium Webdriver Performance testing scenario using Jmeter and Selenium Grid.

1- Install Java 7 or later If necessary

https://java.com/tr/download/

2- Download latest Jmeter version 3.0 or higher.

http://jmeter.apache.org/download_jmeter.cgi

1

3- Download Jmeter PluginsManager JAR file and put it to Jmeter’s lib/ext directory. Then, start JMeter and go to “Options” menu to access the Plugins Manager. Open Jmeter Plugins Manager and Install “Selenium/Webdriver Support” plugin.  Restart Jmeter to take changes for Selenium.

https://jmeter-plugins.org/wiki/PluginsManager/

2

Now you can use the following libraries with numerous script languages !!

Libraries are:

[selenium-firefox-driver, selenium-ie-driver, selenium-chrome-driver, selenium-api, jsyntaxpane, cglib-nodep, phantomjsdriver, commons-exec, selenium-remote-driver, selenium-htmlunit-driver, htmlunit-core-js, sac, selenium-support, cssparser, htmlunit, gson, nekohtml, guava]

4- Download latest stable version of  Selenium Grid (selenium-server-standalone.jar)

http://selenium-release.storage.googleapis.com/index.html

3

NOTE: If you are using Selenium Grid with your own PC, browser windows will be popout at your PC and will be harder. You should test it on your own PC but you will need an test automation machine. I recommend that, you should use a headless Linux ubuntu server for Selenium Grid execution. The following command must be working successfully.

5- Download your browser driver. We will use Chrome driver in this example.

http://www.seleniumhq.org/download/

4

6- Run Selenium Grid Hub

Open the terminal windows or command prompt. Go to the JAR file location and Execute the following command in the first window. This will start the selenium hub.

java -jar selenium-server-standalone-2.53.1.jar -role hub -port 4444

5

7- Register node to Selenium Grid Hub

Go to the JAR file location and Execute the following command in the second new terminal window. This will start and configure the nodes which you will use it for performance testing. If you need to do a performance testing with 100 concurrent users, you must set maxInstances value to 100. The following code only registers the chrome browsers. You should configure it with mixed browser settings as well.

java -jar selenium-server-standalone-2.53.1.jar -role node -hub http://localhost:4444/grid/register -maxSession 100 -browser browserName=”chrome”,version=ANY,platform=WINDOWS,maxInstances=50 -Dwebdriver.chrome.driver=path/to/the/chromedriver/chromedriver_ForMac

6

7

8- Check your Selenium Grid is up and running correctly

8

9- Run Jmeter from bin/jmeter directory. Add the following elements to your project.

  • Right click to Test Plan and Add Threads (Users->Thread Group)
  • Right click to Thread Group and Add Config Element -> Simple Controller
  • Right click to Simple Controller and Add Logic Controller -> jp@gc-Remote Driver Config
  • Right click to Simple Controller and Sampler -> jp@gc WebDriver Sample
  • Right click to Simple Controller and Sampler -> jp@gc WebDriver Sample
  • Right click to Simple Controller and Listeners -> View Results Tree
  • Right click to Simple Controller and Listeners -> Aggregate Graph

9

10- Click Remote Driver Config and write your selenium grid URL. You should change 127.0.0.1 to your real existing selenium grid server IP/url. Change capability to Chrome. If you want to use different browser, you must reRegister node to Grid Hub with different settings.

http://127.0.0.1:4444/wd/hub

10

11- Click WebDriver Sample on the left menu. You should write your test scenarios with a lot of scripting languages to here. You should rename your webdriver samples for understandable test scenarios.

There are some useful examples @this link:

https://jmeter-plugins.org/wiki/WebDriverSampler/

11

12- Write test asserts

Right click to any Webdriver Sampler and Add Assertions→ Response Assertion.

Right click to any Webdriver Sampler and Add Assertions→ Duration Assertion.

Right click to any Webdriver Sampler and Add Assertions→ Size Assertion…..

12

Note: Any response codes except 2xx or 3xx will fail automatically. For example 500 Server Error response code will be automatically fail by Jmeter.

13- View request and response details.(View Results Tree)

13

14- View Overall test results listed or graphical. (Aggregate Graph)

14

15- Run a Load Test with concurrent 10 users(10 Thread). And You should increase this value step by step. Set Loop count for longer testing.

15

That’s it ! 🙂

16

Note: Don’t forget that you must disable or Configure for “Log/Display only Errors” View Results Tree if you don’t use it. If you don’t do that while running load tests with multiple users, You should get not enough memory or memory leaks problems.

javafx

Database Operations in JavaFX

By Onur Baskirt / Apr 1, 2016 / 56 Comments
Before started this section, please check the first article and learn How to Start JAVAFX! http://www.swtestacademy.com/getting-started-with-javafx/ At first, part of JavaFX tutorial series, we created a sample JavaFX project, designed the draft version of the UI and set up an...
rest assured

REST API Testing with Rest Assured

By Onur Baskirt / Mar 8, 2016 / 32 Comments
Outline In this post, I will explain what is API and API testing, what is the difference between SOAP and REST services, and how to test REST APIs with Rest Assured Library. What is API? API stands for Application Programming...
extentreports

How to Write Effective CSS Locators

By Onur Baskirt / Oct 1, 2017 / 0 Comments
Hi all, in this tutorial, I will describe you how to write effective CSS locators to interrogate web elements for your automation projects. As a rule of thumb, your interrogation strategy should be in below order: First try to use...
extentreports

Selenium-11: Execute JavaScript with JavascriptExecutor

By Onur Baskirt / Jan 27, 2016 / 15 Comments
Outline Sometimes we cannot handle some conditions or problems with Webdriver, web controls don't react well against selenium commands. In this kind of situations, we use Javascript. It is useful for custom synchronizations, hide or show the web elements, change...
javafx

Getting Started with JavaFX

By Onur Baskirt / Mar 25, 2016 / 0 Comments
When I started to work in my current position, one of my task is to do manual operations for campaign products  every week. After the second week, I thought that I have to automate this task using a GUI based...
extentreports

How to Write Smart XPath Locators

By Onur Baskirt / Sep 24, 2017 / 4 Comments
Hi all, in this tutorial, I will describe you how to write smart and non-brittle XPath locators. When we write our test scripts, we generally prefer to use id, name, class, etc. these kinds of locators. However, sometimes we could not...
extentreports

Selenium-1: Quick Start to Automation with Selenium WebDriver & JAVA & JUnit & Maven & IntelliJ

By Onur Baskirt / Sep 8, 2015 / 26 Comments
Outline Selenium Webdriver is the most popular open source web test automation framework across wide range of browsers and platforms. In this tutorial you will learn how to do web test automation with Selenium Webdriver and the related tools. Audience...
page object model

Page Object Model with C#

By Ege Aksoz / Jun 18, 2017 / 8 Comments
In the previous tutorial, we’ve taken the initial steps and entered the world of automated testing. We also wrote our first automated test. From this point on, since we are not just going to write one test, we need to...
extentreports

How to Select a Date From DatePicker Using Selenium

By Onur Baskirt / Aug 13, 2016 / 6 Comments
When you need to automate a airway, hotel, or similar websites you need to deal with Datepickers and some times it is a little bit cumbersome to select a specific date on the Datepicker or calendar.  In this post, I...
extentreports

Selenium Webdriver Performance testing with Jmeter and Selenium Grid

By Ozgur Kaya / Aug 9, 2016 / 2 Comments
In this post, we will complete Selenium Webdriver Performance testing scenario using Jmeter and Selenium Grid. 1- Install Java 7 or later If necessary https://java.com/tr/download/ 2- Download latest Jmeter version 3.0 or higher. http://jmeter.apache.org/download_jmeter.cgi 3- Download Jmeter PluginsManager JAR file and...
By | 2017-01-13T21:33:42+00:00 August 9th, 2016|Jmeter, Selenium, Test Automation, Web Automation|2 Comments

About the Author:

Ozgur Kaya
Özgür KAYA is a Senior Software testing and devops professional with 10+ years of experience. He has worked at Turkcell Global Bilgi, Veripark, Turkcell, N11, Trendyol as system & application administrator, test & devops & test automation engineer, test team lead. Now, he is working as Software Testing Team Lead at EFT Software. He is interested in Continuous Integration & Continuous Delivery configurations, Building Test automation framework in everywhere, Build, Release and Deployment Management, Load & Performance & Stress Testing, Application Administering & Monitoring, Security Testing with OWASP rules, Test & QA team management. You can find detailed information about him on his linked-in page.

2 Comments

  1. Ray August 19, 2016 at 9:00 pm - Reply

    Thanks Ozgur! appreciate your contribution to the community.

  2. rajdeep April 7, 2017 at 8:25 am - Reply

    Hi Ozgur, thanks for a wonderful article! I tried to follow the instructions mentioned. However I am facing following error. I am using Ubuntu 14.04 as my Operating System. If you have any information, can you please share.

    ERROR – jmeter.threads.JMeterThread: Test failed! org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities [{proxy={proxyAutoconfigUrl=null, autodetect=false, socksUsername=null, socksPassword=null, httpProxy=null, proxyType=SYSTEM, noProxy=null, ftpProxy=null, socksProxy=null, hCode=XXXXXXXXX, class=org.openqa.selenium.Proxy, sslProxy=null}, browserName=chrome, javascriptEnabled=true, chromeOptions={args=[], extensions=[]}, version=, platform=ANY}]

    Caused by: org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities [{proxy={proxyAutoconfigUrl=null, autodetect=false, socksUsername=null, socksPassword=null, httpProxy=null, proxyType=SYSTEM, noProxy=null, ftpProxy=null, socksProxy=null, hCode=342647017, class=org.openqa.selenium.Proxy, sslProxy=null}, browserName=chrome, javascriptEnabled=true, chromeOptions={args=[], extensions=[]}, version=, platform=ANY}]
    Build info: version: ‘2.52.0’, revision: ‘4c2593cfc3689a7fcd7be52549167e5ccc93ad28’, time: ‘2016-02-11 11:22:43’
    System info: host: ‘hostname’, ip: ‘127.0.1.1’, os.name: ‘Linux’, os.arch: ‘amd64’, os.version: ‘3.13.0-107-generic’, java.version: ‘1.8.0_66’
    Driver info: driver.version: unknown
    at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:115)

Leave A Comment