Search code examples
node.jsnetwork-programminggoogle-chrome-devtoolswebdriver-iopayload

How to retrieve "Request Payload" from Chrome DevTools Network?


I am using WebdriverIO v6.5 to test a web application. I need to pull the JSON "Request Payload" of a certain object, shown here:

Request Payload

To accomplish this, I am using the @wdio/devtools-service (v6.4) service and have created the following method:

Method

However, the method does not print the JSON contents of "Request Payload". It prints other information, but not the needed JSON. Here are the results:

Results

What should I do so that I can properly pull the "Request Payload" JSON contents? Am I in the right direction? Is there an easier way to accomplish this? I feel I am very close, but don't know how to proceed from here.

Thank you!


Solution

  • you can use https://webdriver.io/docs/api/browser/mock.html and get postData from the mock like this yourMock.calls[0].postData