Aused by: org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document

I am able to set the text in normal chrome execution but not in headless?why?


The code is below:

//Designation
WebUI.setText(findTestObject(to'),findTestData('path of data file').getValue(1,rowNum))

The xpath for TxtDesignation is : //*[@id=‘product_designation’]
The DOM is:

If the DOM element was not there it should have failed in normal browser execution.

Thanks

Can’t possibly be your issue but JIC…

image

No the test object is okay i edited it before posting here. The test case is still failing in headless

@Russ_Thomas, Any ideas on this please. I have tried all type of waits but it is still not working

Please follow this advice:

Like the help advises, tell us everything you have tried.

@Russ_Thomas I used WaitForElementPresent and WaitForElementClickable but it did not recognise the xpath even if the same xpath is working well in chrome browser. I even used waitForPageload() but it failed.
I changed the xpath to /html/body/div[3]/div[2]/div/div/div/div[2]/div[2]/div/form/div[2]/div/div[1]/textarea then it worked in headless but this one is too nested and can break my test in the long run.

I still want to use //[@id=‘product_designation’] as the xpath.
If i try to use //
[@name=‘product[designation]’] as well its unable to set the text.
Thanks

waitForElementClickable() is probably not useful here.

Did you try waitForElementVisible() ?

I think you may need to use JavaScript but try waitForElementVisible() first.