I am totally new to scripted web testing and am teaching myself. I have written tests in katalon that identifies web elements using xpath and tests to see if they are present. When I run these tests in chrome or firefox, they pass but if I run them using headless browser execution they fail.
Here is an example of one failure:
com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Main page ITSI/ITSI Login Page top half elements.st/div_logo’ located by ‘By.xpath: /html/body/header/a/div’ not found
Here is the line from the test:
WebUI.verifyElementPresent(findTestObject(‘Main page ITSI/ITSI Login Page top half elements.st/div_logo’), 5, FailureHandling.CONTINUE_ON_FAILURE)
Is there something I need to do to get these tests to work in headless test execution?
Is there no way to use xpath for web elements and test in headless mode?
Try to takescreenshoot before, and see in report is it really not show in UI or not.
in my experience headless browser in ubuntu server, it will run in different viewport width 800x , so for responsive website it will change some element layout (even hide) at that screen size. you need to specify chrome headless window size if that happen
The tests should work the same when using the UI or Headless. I have several scripts that wait for Elements and I don’t see issues when using the Headless mode. If it’s not finding the element, that could be related to timing and the item not appearing on the page as expected. Does it make any difference if you increase the wait time or use the Delay command and set a specific wait?
I have tracked this further. It seems to only fail on chrome headless, it works fine with FF headless. I have no idea why this is the case.