Running test scripts in Headless browser

Test case is about adding a category and verify its added and then deleted the added category.
It works fine if I run the script in chrome browser but it fails if executed in headless chrome.
In headless script is failing as below (i am using katalon 7.3.1)

I have set the resolution as
WebUI.setViewPortSize(1366, 784, FailureHandling.CONTINUE_ON_FAILURE)


WebUI.click(findTestObject(‘Products/Add Category to a product/span_Type Category’))

println(“$NewCategory”)

WebUI.setText(findTestObject(‘Products/Add Category to a product/Search Category’), NewCategory)

WebUI.sendKeys(findTestObject(‘Products/Add Category to a product/Search Category’), Keys.chord(Keys.ENTER))

WebUI.waitForElementClickable(findTestObject(‘Products/Add Category to a product/button_Add category’), 20)

WebUI.click(findTestObject(‘Products/Add Category to a product/button_Add category’))
//WebUI.delay(5)

String AddedCategory = WebUI.getText(findTestObject(‘Products/Add Category to a product/Heading of new category’))

println(“$AddedCategory”)

if (AddedCategory == NewCategory)
{

WebUI.verifyElementPresent(findTestObject('Products/Add Category to a product/a_Remove'), 5)

WebUI.click(findTestObject('Products/Add Category to a product/a_Remove'))

WebUI.verifyAlertPresent(5)

WebUI.acceptAlert()

} else
{
assert false
}