Headless Browsers Execution


This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/headless-browsers-execution.html

Will we eventually be able to do headless testing on Edge?

My Headless Browser executions keep failing. Mostly Chrome(headless) fails. But in some cases, firefox too. Below is the error message I see. Please help. Thank you

Verify element text of test object ‘Object Repository/Page_AlertFind/span_User List’ FAILED. (Root cause: com.kms.katalon.core.exception.StepFailedException: Verify element text of test object ‘Object Repository/Page_AlertFind/span_User List’ FAILED.

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)

at com.kms.katalon.core.webui.keyword.builtin.VerifyElementTextKeyword.verifyElementText(VerifyElementTextKeyword.groovy:72)

at com.kms.katalon.core.webui.keyword.builtin.VerifyElementTextKeyword.execute(VerifyElementTextKeyword.groovy:40)

at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:72)

at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementText(WebUiBuiltInKeywords.groovy:3663)

at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementText$3.call(Unknown Source)

at C25731044 - MOAFCID-33217 - E2E test to create a dedicated regular user for QA with standard devices configured for bytestacker customer.run(C25731044 - MOAFCID-33217 - E2E test to create a dedicated regular user for QA with standard devices configured for bytestacker customer:65)

at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)

at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)

at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)

at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)

at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)

at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)

at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)

at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:169)

at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:142)

at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:91)

at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)

at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)

at TempTestSuite1582718925380.run(TempTestSuite1582718925380.groovy:36)

Caused by: com.kms.katalon.core.exception.StepFailedException: Actual text ‘’ and expected text ‘User List’ of test object ‘Object Repository/Page_AlertFind/span_User List’ are NOT matched.

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)

at com.kms.katalon.core.webui.keyword.builtin.VerifyElementTextKeyword$_verifyElementText_closure1.doCall(VerifyElementTextKeyword.groovy:57)

at com.kms.katalon.core.webui.keyword.builtin.VerifyElementTextKeyword$_verifyElementText_closure1.call(VerifyElementTextKeyword.groovy)

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)

… 19 more

)

I think you should add some of the explicit or implicit wait to your test scripts and check again if the test still fail.

Hi, I am having exactly the same error as yours!! Did you find a solution already?

Thanks!

You can try “waitForElementVisible”. This actually solved my issue. Please try and use timeout as 5 mins or so just to be sure. 300 seconds. Please let me know if it works for you too. :slight_smile:

Thank you for the quick reply! I tried the method you mentioned to wait for element visible for 300 sec, but still out of luck. I think it might be an issue related with my element class attribute which is hidden. Which not make sense that while I run a script in Chrome, the element pass just fine. However, while I run the same script in Chrome headless, now the element won’t be visible no more no matter how long I wait. Anyway, I am really appreciate your help!

Hi I am getting the same behavior. Did you get to find a solution? I appreciate your help

Why ks 7.6 does not support part from chrome driver.pls anyone give the solution

Dear,


I cannot input a value in the Value cell.

Hi @mthuvtb42

You should click on the Value cell then click on the square button at the right conner to edit the value of the selected desired property.

Untitled

I often find my tests pass consistently in GUI mode but fail in Headless mode for reasons like ‘Element not Interactable’ or ‘Element Intercepted’. I am slowly converting these failed clicks to JavaScript clicks, but feels like I’m losing a lot of the value of the Katalon ‘Click’ keyword by doing this across many test cases and steps.
Does anyone have any useful feedback on this issue? I have seen it mentioned many times in posts, and ‘JavaScript’ clicks seem to always be the most consistent answer (if ‘wait’ or ‘wait until element…’ keywords don’t work), but I’m curious what Katalon has to say about why their own ‘Click’ keyword is not reliable to use in Headless mode, which is the standard for testing in modern CI/CD pipelines?

Who said headless mode is the standard in modern testing?
As far as i know headless mode is mostly used by developers to quickly rander the DOM.
Have no connection with propper UI testing where a real display may be needed… Oor at least a virtual one

1 Like

ya, I like the UI mode, but my management team continually pushes me towards headless testing so we can integrate with Jenkins and run these tests more quickly in scenarios like when PR’s are created and/or merged. Should I look into running these tests in UI mode on a remote machine? Any guidance on where I can find more info on the correct standards to apply/>

Your management team is confused.
You can execute relevant ui tests in docker containers on a headless machine using the normal webdriver (because xvfb, this i why we have it)
Or yeah, even better, remote execution on a relevant cloud stack or self hosted grid.
That will be modern testing.

And yeah, all off them can be done through jenkins or any other CI tool

1 Like

thank you for this feedback! I really appreciate it.

I have used the settings as instructed for headless chrome. However, it still opens chrome.

Hello everyone, I having issues running test cases on headless chrome, one of my test need to check the value of an span element that by default is 0 but when server response, change it value with another number value, so I’m checking this value is greater than some value. On UI chrome the test run fine, but with headless version it always getting the 0 value and fail, but if I set a 3 seconds delay before that validation, the test got pass. My question is, is there a way to wait until element change it html value?

There is no keyword named “WebUI.waitForElementText” nor “WebUI.verifyElementText” which wait for condition to be true. But there is an alternative. You can use “WebUI.waitForElementPresent” or “WebUI.verifyElementPresent”. These keywords have “timeout” parameter. These can wait for the target element turned to be present.

You want to specify a TestObject with a XPath locator. The locator should look for an HTML element of which content text is equal to the value you expect. The following code demonstrates my idea.

import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

WebUI.openBrowser("")
WebUI.navigateToUrl("http://demoaut.katalon.com/")
//TestObject tObj = createTestObject("//a[text()='Make Appointment']")    // should PASS
TestObject tObj = createTestObject("//a[text()='Make DisAppointment']")   // should FAIL
// the following waits for the HTML element to be present for 3 seconds,
// would pass if found in 3secs, would fail if not found in 3secs
boolean b = WebUI.verifyElementPresent(tObj, 3, FailureHandling.CONTINUE_ON_FAILURE)  
WebUI.comment("present? : ${b}")
WebUI.closeBrowser()

//
TestObject createTestObject(String xpath) {
	TestObject tObj = new TestObject(xpath)
	tObj.addProperty("xpath", ConditionType.EQUALS, xpath)
	return tObj
}