How to make decision when running on headless browser or normal browser

I need to run script well when running on headless or normal browser, the problem is when we running on headless browser we can’t use waitelementvisible because it will fail testcase, i have other solution for this but i need make decision statement for that, like
if (test running on headless){
runthiscode
} else if (test running on normal){
runthiscode
}
anyone know the solution please answer my question. Thanks.

This may be what you want:

https://api-docs.katalon.com/studio/v4.6.0/api/com.kms.katalon.core.webui/com/kms/katalon/core/webui/driver/DriverFactory.html#getExecutedBrowser()

1 Like

I am afraid that the above URL points to the v4.6.0 documentation. The document seem to be outdated.
I tried DriverFactory#getExecutedBrowser() method but unable to compile.

1 Like

I made a Test Case:

import com.kms.katalon.core.webui.driver.DriverFactory as DF
import com.kms.katalon.core.webui.driver.WebUIDriverType
WebUI.openBrowser('')
WebUI.navigateToUrl('http://demoaut.katalon.com/')
WebUIDriverType dt = DF.getExecutedBrowser()
WebUI.comment("WebUIDriverType is ${dt}")

This emitted:

WebUIDriverType is Firefox (headless)
2 Likes

kazurayam said:

I made a Test Case:

import com.kms.katalon.core.webui.driver.DriverFactory as DF

import com.kms.katalon.core.webui.driver.WebUIDriverType
WebUI.openBrowser(‘’)
WebUI.navigateToUrl(‘http://demoaut.katalon.com/’)
WebUIDriverType dt = DF.getExecutedBrowser()
WebUI.comment(“WebUIDriverType is ${dt}”)


This emitted:  

WebUIDriverType is Firefox (headless)


  

thank you for the solution @4280-kazurayam :slight_smile: