Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JMeter Plugin for Recording API Traffic while we interact with application's UI using selenium #6416

Open
Yashas-N-R opened this issue Jan 29, 2025 · 0 comments

Comments

@Yashas-N-R
Copy link

Use case

Problem:
In many testing workflows, functional tests (using Selenium or similar tools) and performance tests (using JMeter or other load-testing tools) are handled separately. This separation makes it harder to reuse work done in functional testing for performance testing.
Use Case:
By recording API calls made during Selenium browser interactions, this plugin bridges the gap between UI functional testing and backend performance testing.
Teams can automate their functional workflows in Selenium and automatically replicate those workflows as API test plans in JMeter for performance testing.

Possible solution

The plugin workflow will involve:

Selenium Automation:

Use Selenium to open the application in Firefox (or other browsers), interact with the UI (clicks, scrolling, form submissions, etc.), and perform actions that trigger API calls.

Integrating JMeter's Proxy Recorder:

Leverage JMeter's HTTP(S) Proxy Recorder (ProxyControl) to intercept all HTTP/HTTPS traffic from the browser.
Configure Selenium WebDriver with a proxy pointing to JMeter's Proxy Recorder (localhost:8888) to route its traffic through JMeter.

Dynamic Conversion of API Requests:

Parse intercepted HTTP/HTTPS requests and dynamically convert them into JMeter HTTP Samplers (e.g., HTTPSamplerProxy) that are added to the Recording Controller in JMeter.

Output: A JMeter Test Plan:

All requests are captured and added to a JMeter Test Plan in real-time. This test plan can then be used for performance or load testing with multiple virtual users.

Possible workarounds

Start JMeter’s Proxy Recorder:

Open JMeter, add an HTTP(S) Test Script Recorder.
Configure the Proxy Server to listen on localhost:8888 (or another port of your choice).
Ensure the recorder's target controller is set to your Recording Controller.
Manually Configure the Proxy in Selenium:

Configure Selenium’s WebDriver proxy settings to use JMeter’s recorder. A dummy Java example:

Proxy proxy = new Proxy();
proxy.setHttpProxy("localhost:8888");
proxy.setSslProxy("localhost:8888");

FirefoxOptions options = new FirefoxOptions();
options.setProxy(proxy);

WebDriver driver = new FirefoxDriver(options);
driver.get("https://example.com");

// Perform interactions with the page
WebElement element = driver.findElement(By.id("button"));
element.click();
Automate and Record API Traffic:

As you interact with the browser through Selenium, the HTTP(S) Test Script Recorder captures and converts the API traffic into HTTP Samplers stored in the Recording Controller.
Generate and Save the Test Plan:

Once done, save the Recording Controller’s content as a .jmx file. This becomes your test plan for API load testing.

JMeter Version

5.6.3

Java Version

No response

OS Version

Microsoft windows 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant