I am researching the differences between Selenium and JMeter and I stumbled across the following statement about Selenium:

Even though WebSocket might be encapsulated into a web session and affect the browser, the user/Selenium will not realise it. So, we will use JMeter for testing WebSockets.

which confuses me because even though Selenium can't detect that specific scenario, Selenium still uses a programming language like JAVA, hence you can still use Java to accomplish the same thing JMeter does in this case. Or am I missing something here?

2 Answers 2


Both of these tools, Selenium and JMeter, are useful for different purposes.

As mentioned on the Selenium website:

Selenium automates browsers. That's it! Primarily, it is for automating web applications for testing purposes.

In other words, it's used to validate user behavior and testing of end-to-end functional scenarios in the browser. This is the primary purpose. Yes, people use Selenium for other purposes like web scrapping, but these are seen as secondary uses. "Performance testing" using Selenium is not the same as using JMeter; this is meant to read as "how fast can you perform UI tests for a single user." You cannot use Selenium to simulate heavy load, web traffic, 100's or 1000's of users at a time.

As mentioned on the JMeter website:

Apache JMeter may be used to test performance both on static and dynamic resources, Web dynamic applications. It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types.

In other words, the primary purpose with JMeter is as a load and performance testing tool. While it has expanded to other types of testing, load and performance is it's primary purpose.

Yes, they both can be used with Java, but this is an implementation detail. Selenium can also be used in other programming languages like C#, PHP, JavaScript, Ruby, Python.

What's your main purpose?

If it's front-end/UI web app functional behavior and validation, go with Selenium.

If it's load and performance testing, anything at the web socket layer, go with JMeter.

Note: OP's question and quote seems to relate to this article: https://www.blazemeter.com/blog/selenium-vs-jmeter-which-one-should-you-choose-and-when/

This article goes on to say:

Can Selenium do everything that JMeter does?

No. Selenium can be used for some performance testing (e.g. limited bandwidth testing), but it cannot be used to load test with accuracy like JMeter.

Can JMeter do everything that Selenium does?

No. JMeter can record detailed web sessions originated by web browser applications and replay the web session as the server sees them. However, each replay does not reproduce client side elaboration (e.g. Javascript logic in web browser) or web page rendering. So if our test is focused on how a web page is presented to a user, Selenium is a better choice.

Can JMeter and Selenium collaborate? Yes. There are various situations where both tools can sync on the same testing application.

The record and replay in JMeter is similar to using Selenium IDE browser extension.

  • Hmm but this doesn't answer my question that I have posted. The specific statement that I mentioned cant you achieve that using Java hence making JMeter not needed in that scenario?
    – ali
    Commented Oct 16, 2019 at 15:57
  • @ali My answer is aimed at the title and general use cases of your question: the differences between the two tools. I understood your question to also mean "can JMeter and Selenium be used interchangeably?" Which is no, they can't. While my answer is still very useful, can you clarify your question? What specifically are you confused about?
    – Lee Jensen
    Commented Oct 16, 2019 at 16:45

I don't know what you're reading however I would recommend stopping referring this source as they don't really realize what they're talking about.

According to The WebSocket API documentation:

The WebSocket API is an advanced technology that makes it possible to open a two-way interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.

Selenium is browser automation framework therefore you get this WebSocket API support "for free". If you need to perform some custom use cases you can use JavascriptExecutor to call WebSocket object functions.

When it comes to JMeter:

JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).

Therefore JMeter will not trigger any WebSocket-related events unless you use a plugin and manually open connection, send message, read response, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.