# How to get the request payload from recorded Katalon test case

**URL:** <https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [January 14, 2023, 4:36am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320 "2023-01-14T04:36:12Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![hewin9](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/hewin9/32/22419_2.png) [@hewin9](https://forum.katalon.com/u/hewin9)\
**Post date:** [January 14, 2023, 4:36am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320/1 "2023-01-14T04:36:12Z")

</div>

I used Katalon Studio’s Record Web tool to record a a series of clicks on a website, it includes some POST request. I have a lot of pages and want to get the request payload content for each page, so I would like to use Katalon to record the steps for each page and get the request payload for each page. I clicked the script tab of the recorded test case and here is a sample of the script:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint  
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase  
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData  
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject  
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject  
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint  
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW  
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile  
import com.kms.katalon.core.model.FailureHandling as FailureHandling  
import com.kms.katalon.core.testcase.TestCase as TestCase  
import com.kms.katalon.core.testdata.TestData as TestData  
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW  
import com.kms.katalon.core.testobject.TestObject as TestObject  
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS  
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI  
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows  
import internal.GlobalVariable as GlobalVariable  
import org.openqa.selenium.Keys as Keys  
import com.kms.katalon.core.testobject.RequestObject  
import com.kms.katalon.core.testobject.ResponseObject  
import com.kms.katalon.core.webservice.verification.WSResponseManager

WebUI.openBrowser(‘’)  
WebUI.navigateToUrl(‘[https://www.URL.com](https://www.URL.com)’)  
WebUI.setText(findTestObject(‘Object Repository/Page\_Login/input\_Username\_username’), ‘username’)  
WebUI.setEncryptedText(findTestObject(‘Object Repository/Page\_Login/input\_Password\_password’),  
‘some password’)  
WebUI.click(findTestObject(‘Object Repository/Page\_Login/div\_LOG IN’))  
WebUI.click(findTestObject(‘Object Repository/Page\_Settings/span\_User Profile’))  
WebUI.doubleClick(findTestObject(‘Object Repository/Page\_Settings/input\_Update Interval every’))  
WebUI.click(findTestObject(‘Object Repository/Page\_Settings/button\_Accept’))  
RequestObject request = WSResponseManager.getInstance().getCurrentRequest()  
System.out.println(request)  
WebUI.closeBrowser()

I added these to try to print out the request object but I got null in the console.  
RequestObject request = WSResponseManager.getInstance().getCurrentRequest()  
System.out.println(request)

Any idea how I can get the request payload?

---

<div class="post-metadata">

**Author:** ![Dave\_Evers](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/dave_evers/32/435_2.png) [@Dave\_Evers](https://forum.katalon.com/u/Dave_Evers)\
**Post date:** [January 14, 2023, 7:56am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320/3 "2023-01-14T07:56:21Z")

</div>

Hi @hewin9, Try doing a Google search for “Katalon api video”, for example: [katalon api video - Google Search](https://www.google.com/search?q=katalon+api+video&source=hp&ei=NWDCY9vLAcHH0PEP-Jq0sA0&oq=&gs_lcp=ChFtb2JpbGUtZ3dzLXdpei1ocBABGAAyBQgpEKABMgYIKRAWEB4yBQgpEIAEMgIIKTIFCCkQgAQyBwgpEIAEEA0yBQgpEIAEMgUIKRCABDICCCkyAggpMgsIKRCABBCxAxCDATIFCCkQkQIyAggpMggIKRCABBCxAzIFCCkQgAQyDggAEI8BEOoCEIwDEOUCMg4IABCPARDqAhCMAxDlAjIOCAAQjwEQ6gIQjAMQ5QIyDggAEI8BEOoCEIwDEOUCMg4IABCPARDqAhCMAxDlAjIOCAAQjwEQ6gIQjAMQ5QIyDggAEI8BEOoCEIwDEOUCMg4IABCPARDqAhCMAxDlAjIOCAAQjwEQ6gIQjAMQ5QIyDggAEI8BEOoCEIwDEOUCMg4IABCPARDqAhCMAxDlAjIOCAAQjwEQ6gIQjAMQ5QIyDggAEI8BEOoCEIwDEOUCMg4IABCPARDqAhCMAxDlAjIOCAAQjwEQ6gIQjAMQ5QJQAFgAYIIPaAFwAHgAgAEAiAEAkgEAmAEAsAEe&sclient=mobile-gws-wiz-hp)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [January 14, 2023, 9:23am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320/4 "2023-01-14T09:23:21Z")

</div>

> [@hewin9](#):
>
> I added these to try to print out the request object but I got null in the console.  
> RequestObject request = WSResponseManager.getInstance().getCurrentRequest()

You have a misunderstanding. `WebUI.*` keywords and `RequestObject` has nothing to do with each other.

* * *

See my post:

[http://forum.katalon.com/t/sample-usage-of-browsermob-proxy-in-katalon-studio/83322](http://forum.katalon.com/t/sample-usage-of-browsermob-proxy-in-katalon-studio/83322)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [January 15, 2023, 12:51am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320/8 "2023-01-15T00:51:18Z")

</div>

Your requirement will be met quite easily if you choose Chrome Devtools Protocol-based test tools, for example Playwright: See their doc

> **[Network | Playwright](https://playwright.dev/docs/network#network-events)**
>
> Introduction

> You can monitor all the Requests and Responses:

```auto
const { chromium, webkit, firefox } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();

  // Subscribe to 'request' and 'response' events.
  page.on('request', request =>
      console.log('>>', request.method(), request.url()));
  page.on('response', response =>
      console.log('<<', response.status(), response.url()));
  await page.goto('https://example.com');

  await browser.close();
})();

```

The Playwright speaks to Chrome browser via [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/), not via [W3 WebDriver protocol](https://www.w3.org/TR/webdriver1/). Due to the difference in the protocol’s scope & capabilities, CDP-based software is capable of some featueres that Selenium3 WebDriver-based software will never be.

You may want to look at [Playwright](https://playwright.dev/). They provide [codegen](https://playwright.dev/docs/codegen), which is a record & playback tool.

---

<div class="post-metadata">

**Author:** ![hewin9](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/hewin9/32/22419_2.png) [@hewin9](https://forum.katalon.com/u/hewin9)\
**Post date:** [January 19, 2023, 3:38am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320/9 "2023-01-19T03:38:42Z")

</div>

Thanks for the help. The BrowserMob Proxy works like a charm. The generated har file is quite large but I am ok with it. Is there a way to just write the POST request or GET request to har file?

---

<div class="post-metadata">

**Author:** ![hewin9](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/hewin9/32/22419_2.png) [@hewin9](https://forum.katalon.com/u/hewin9)\
**Post date:** [January 19, 2023, 3:44am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320/10 "2023-01-19T03:44:30Z")

</div>

Thank you @kazurayam for the Playwright solution. It also works but Katalon is better at capturing the web elements than Playwright.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [January 19, 2023, 6:11am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320/11 "2023-01-19T06:11:35Z")

</div>

> [@hewin9](#):
>
> Is there a way to just write the POST request or GET request to har file?

jq command is well-known and heavily used in the open source world to process JSON in general

[https://stedolan.github.io/jq/](https://stedolan.github.io/jq/)

for mac and linux

> **[Guide to Linux jq Command for JSON Processing | Baeldung on Linux](https://www.baeldung.com/linux/jq-command-json)**
>
> Explore the capabilities that jq provides for processing and manipulating JSON via the command line.

for windows

> **[How to install and use 'jq' on Windows | bobbyhadz](https://bobbyhadz.com/blog/install-and-use-jq-on-windows)**
>
> The easiest way to install jq on Windows is to use the \`choco install jq -y\` command.

You can write a Groovy Script (Test Case) that call jq as os command:

[https://docs-dev.katalon.com/docs/author/keywords/using-keywords-in-katalon-studio/windows-testing/execute-windows-commands-in-katalon-studio](https://docs-dev.katalon.com/docs/author/keywords/using-keywords-in-katalon-studio/windows-testing/execute-windows-commands-in-katalon-studio)

---

<div class="post-metadata">

**Author:** ![hewin9](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/hewin9/32/22419_2.png) [@hewin9](https://forum.katalon.com/u/hewin9)\
**Post date:** [January 19, 2023, 6:22am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320/12 "2023-01-19T06:22:39Z")

</div>

Yes, I can use other script to parse the json result. But if the BrowserMob Proxy can filter the POST and GET reuqest then the har file will be smaller for later process.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [January 19, 2023, 6:23am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320/13 "2023-01-19T06:23:25Z")

</div>

> [@hewin9](#):
>
> if the BrowserMob Proxy can filter …

I don’t know.  
Please study yourself.  
If you could find how to, please share it for the others.

---

<div class="post-metadata">

**Author:** ![hewin9](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/hewin9/32/22419_2.png) [@hewin9](https://forum.katalon.com/u/hewin9)\
**Post date:** [January 19, 2023, 6:33am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320/14 "2023-01-19T06:33:04Z")

</div>

Ok, thanks @kazurayam

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [January 21, 2023, 7:41am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320/15 "2023-01-21T07:41:57Z")

</div>



---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [January 22, 2023, 1:22am UTC](https://forum.katalon.com/t/how-to-get-the-request-payload-from-recorded-katalon-test-case/83320/16 "2023-01-22T01:22:08Z")

</div>

> [@hewin9](#):
>
> It also works but Katalon is better at capturing the web elements than Playwright.

I think that Playwright is good in capturing the web elements as well; as good as KS, but in completely different syntax. You have to write test in JavaScript/TypesScript in Playwright.

I would prefer JavaScript’s `"(async () => {await ...})()"` syntax to WebDriver’s [`"new WebDriverWait(driver, timeout).until(condition)"`](http://forum.katalon.com/t/cannot-cast-object-cchromedriver-error/83552/6) instruction in Java.
