Headless Chome - Opens mobile chrome browser instead of desktop version

I have a problem with Headless Chrome.
I have a test case where it has to put mouse over a menu, open the dropdown and click on an object.
It works fine when I run it in Chrome but it doesn’t run in headless.
From the screenshot in TestOps I see that when the browser opens in headless it is not desktop it is mobile so the menu dropdown isn’t visible and it can’t find the object and of course it fails.

Does anyone know why in headless it opens mobile version of chrome?


In this case, you should save the page source to a file then evaluate the page source file.
Sample script to save the page source:

import org.apache.commons.io.FileUtils

import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI


String pageSource = DriverFactory.getWebDriver().getPageSource()
File file = new File(RunConfiguration.getProjectDir(), "page_source.html") //This file will save under project folder
FileUtils.write(file, pageSource)

I am having the same issue. Chrome works fine with all the object repositories. Running it via Chrome (headless) gives error messages…
Unable to click on object ‘Object Repository/Page_Login/input_Username’
Any Suggestions!