Headless Chrome Browser - getting StaleElementReferenceException for some elements

Hello Guys,

I am getting ‘StaleElementReferenceException’, only if I execute the Testcase from Chrome Headless Browser.
if the same script executes from the chrome browser then it is running properly without any error.

also set screen resolution into chrome headless properties.

Below is the code.

WebUI.waitForElementClickable(findTestObject(‘Page_Sign in to your account/input_Sign in_idSIButton9 (1)’), 45)
WebUI.click(findTestObject(‘Page_Sign in to your account/input_Sign in_idSIButton9 (1)’))

We need to see the error log.

code is below -
WebUI.waitForElementClickable(findTestObject(‘Page_Sign in to your account/input_Sign in_idSIButton9 (1)’), 45)

WebUI.click(findTestObject(‘Page_Sign in to your account/input_Sign in_idSIButton9 (1)’))

Reminder: I explained the cause(s) of this kind of error in our private exchange.

Question: Just as a data point, what does Firefox headless do?

this is the screenshot for Firefox headless browser execution.

and as you are talking about the cause of stale element after page is loaded I am not refreshing the page.

and the same code is working for chrome browser but not for headless.

That’s a completely different error with very different causes. What you’ve almost proved is, Chrome/Firefox headless behave differently.

This concerns me…

Stale elements (which I wish were called Stale Test Objects) are generally caused by page updates (not actual page refreshes). Please don’t confuse the two - you’ll confuse us in the process.

Your page, like it or not, is changing during the test case. You need to deal with it. Where in the test life-cycle that is happening is a question for you. Share more of your test code, mark out WHERE the error occurs and we’ll see if we can help pin it down.