jmeterjmeter-plugins

Capture WebDriver requests in Jmeter


One of the services I gonna test using Jmeter has complex authorization mechanism that requires some CS-based steps (JavaScript). So, to set up a session, I have to use WebDriver as Jmeter can't (and actually shouldn't) process JS.

I do it in the following way: at the beginning of each thread I open the resource in real browser (via Jmeter WebDriver plugin), complete authorization, store browser cookies that was set up by server and then use these cookies to generate load using standard Jmeter logic within defined HTTP-session.

This schema works fine and I successfully use it in different load tests.

But now the service I test requires not only cookies but also some important parameters that browser sends in POST as a part of authorization process. To prove that my requests belong to the same session, I should extract some sensitive parameters not from response (it can be easily done) but from request. I can't find these values stored anywhere in DOM and it seems like these values are generated by JS attached to response page.

So, my question is: is there a way to capture parameters from request sent by WebDriver?

I understand that all requests done by browser initiated in Jmeter are not visible to it. And the only idea I see is to use Jmeter request recorder dynamically:

  1. Open browser window.

  2. Define Jmeter as a proxy for this browser.

  3. Capture requests sent by browser in Jmeter using recorder.

  4. Somehow extract sensitive data from requests.

  5. Use the data to generate load.

Any ideas appreciated. Thanks in advance!


Solution

  • Solved the issue by running local proxy server (BrowserMob Proxy project) using BeanShell sampler. I retarget the WebDriver Sampler to this proxy, perform required actions using browser, then store captured data in HAR format and process it (extract required data from requests). Then just store valuable request parameters in variables (or properties) and use them in a regular way in HTTP sampler to generate load. Hope it can help anyone else in future.