How to determine if I'm running headless mode in code or otherwise?

I’m primarily using the Firefox driver to run all of my scripts. There may be instances that members of my team will use the headless browser option and some not.

How can I determine in the script how its being ran? I’d like to catch if its in headless mode. Pseudo code example:

if (Driver.headlessBrowser)

Do stuff and things


1 Like

Hi. Try

import com.kms.katalon.core.webui.driver.DriverFactory
println DriverFactory.getExecutedBrowser().getName() //'HEADLESS_DRIVER'

Same as suggested before try this approach:


System.out.println(‘Headless browser is being used’)

else {

System.out.println('Regular browser is used')