This page looks best with JavaScript enabled

Distributed testing using jMeter and SeleniumGrid

 ·  🎃 kr0m

As explained in a previous article, SeleniumGrid is a remote system for executing web browsers. This time we will combine jMeter + SeleniumGrid to perform distributed tests while taking advantage of all the facilities that jMeter provides.

Before starting with the tests, we will set up a SeleniumGrid as described in this previous article. However, when using SeleniumGrid from jMeter, there are certain limitations such as not being able to pass the necessary browser configuration parameters. We should send the parameters:

    "args": [
      "--headless",
      "--no-sandbox",
      "--disable-dev-shm-usage"
    ]

Instead, we send:

    "args": [
    ],

It seems that there is no solution, as we cannot indicate the goog:chromeOptions through jMeter:
https://stackoverflow.com/questions/49239525/how-to-use-chromeoption-and-desirecapabilities-in-jmeter-webdriver-sampler/

Looking into ChromeDriverConfig.java it isn’t something you can currently control with the WebDriver Sampler.

In the SeleniumGrid node, we will have to start a reduced graphical server like Xvfb before joining the network. This way, instead of running in headless mode, the browser will run inside this graphical server:

vi /etc/portage/package.use/xorg-server

x11-base/xorg-server -ipv6 -libglvnd -suid -udev -xorg -debug -dmx -doc -elogind -kdrive -libressl -minimal -selinux -static-libs -systemd -unwind -wayland -xcsecurity -xephyr -xnest xvfb
emerge -av x11-base/xorg-server
Xvfb :0 -ac -screen 0 1024x768x24 &

Now we can connect the node to the network:

your selenium -l
export DISPLAY=:0
java -Dwebdriver.chrome.driver=chromedriver -Dwebdriver.gecko.driver=geckodriver -jar selenium-server-standalone-3.141.59.jar -role node -hub http://{{ip or host}}:4444/grid/register/ -port 4444

Once we have the SeleniumGrid ready to work with jMeter, we create a test plan and add a Thread Group:

Right-click on "Test Plan"
Add -> Threads (Users) -> Thread Group

We add a Remote Driver Config to the Thread Group:

Right-click on "Thread Group"
Add -> Config Element -> jp@gc-Remote Driver Config

The configuration will be as follows:
http://kr0mtest:4444/wd/hub

Now we add the WebDriver Sample that will make the test requests:

Right-click on "Thread Group"
Add -> Sampler -> jp@gc WebDriver Sample

The script will be as follows:

WDS.sampleResult.sampleStart()
WDS.browser.get('http://alfaexploit.com/archive')
WDS.sampleResult.sampleEnd()

We add a couple of listeners to see the results:

Right-click on "Thread Group"
Add -> Listeners -> View Results Tree
Right-click on "Thread Group"
Add -> Listeners -> Response Time Graph

All that remains is to run the test (graphically or via CLI) and it will be sent to the SeleniumGrid where the load will be distributed among the different nodes.

As a final note, I leave a very interesting video about jMeter + Selenium:
https://www.youtube.com/watch?v=RdPCl8yQnR4

If you liked the article, you can treat me to a RedBull here