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
import com.kms.katalon.core.driver.DriverType
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI



DriverType driverType = DriverFactory.getExecutedBrowser()



You will see

2019-02-03 16:28:47.908 INFO  c.k.k.c.keyword.builtin.CommentKeyword   - driverType=Chrome (headless)
1 Like

Hi there,
this code is working when I select the headless chrome button:
button it’s not when I using this code:
ChromeOptions chromeProfile = new ChromeOptions()

Please help me to show this problem

In this code, you already know that you are using Chrome Headless mode. You don’t need to be told, do you?

yes , actually I can use 1 key=true when using that code, but I think maybe has the best way to get headless mode. Some case, there are 2 different displays for 1 flow test, so I have to write for both in 1 file script

You can manage it anyway.

1 Like