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

**URL:** <https://forum.katalon.com/t/aused-by-org-openqa-selenium-staleelementreferenceexception-stale-element-reference-element-is-not-attached-to-the-page-document/45343>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [July 7, 2020, 9:56pm UTC](https://forum.katalon.com/t/aused-by-org-openqa-selenium-staleelementreferenceexception-stale-element-reference-element-is-not-attached-to-the-page-document/45343 "2020-07-07T21:56:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anuradha](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/anuradha/32/16103_2.png) [@anuradha](https://forum.katalon.com/u/anuradha)\
**Post date:** [July 7, 2020, 9:56pm UTC](https://forum.katalon.com/t/aused-by-org-openqa-selenium-staleelementreferenceexception-stale-element-reference-element-is-not-attached-to-the-page-document/45343/1 "2020-07-07T21:56:44Z")

</div>

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

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/5/5385b80c16a59807e188eaeda0674660df1efad8.png)  
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:  
 ![image](https://europe1.discourse-cdn.com/katalon/optimized/2X/6/6df0a9a608f9c90df455ca6211590249f3855617_2_690x52.png)

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

Thanks

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [July 7, 2020, 11:55pm UTC](https://forum.katalon.com/t/aused-by-org-openqa-selenium-staleelementreferenceexception-stale-element-reference-element-is-not-attached-to-the-page-document/45343/2 "2020-07-07T23:55:01Z")

</div>

Can’t possibly be your issue but JIC…

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/1/153b75952de9bd240846e230aa53aa7e5921434c.png)

---

<div class="post-metadata">

**Author:** ![anuradha](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/anuradha/32/16103_2.png) [@anuradha](https://forum.katalon.com/u/anuradha)\
**Post date:** [July 8, 2020, 3:01am UTC](https://forum.katalon.com/t/aused-by-org-openqa-selenium-staleelementreferenceexception-stale-element-reference-element-is-not-attached-to-the-page-document/45343/3 "2020-07-08T03:01:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anuradha](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/anuradha/32/16103_2.png) [@anuradha](https://forum.katalon.com/u/anuradha)\
**Post date:** [July 8, 2020, 10:19am UTC](https://forum.katalon.com/t/aused-by-org-openqa-selenium-staleelementreferenceexception-stale-element-reference-element-is-not-attached-to-the-page-document/45343/4 "2020-07-08T10:19:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [July 8, 2020, 12:49pm UTC](https://forum.katalon.com/t/aused-by-org-openqa-selenium-staleelementreferenceexception-stale-element-reference-element-is-not-attached-to-the-page-document/45343/5 "2020-07-08T12:49:16Z")

</div>

> [@anuradha](#):
>
> Any ideas on this please.

Please follow this advice:

> [@\[TIP\] How To Help Us Help You!](http://forum.katalon.com/t/tip-how-to-help-us-help-you-my-test-is-broken-nothing-works-updated-nov-2019/12919):
>
> My test is BROKEN! NOTHING WORKS! HELP ME! Relax. We get it. We really do. There are some pretty smart and clever people on this forum, but you must realize, they are not magicians or wizards or gods. They cannot see your code, they can’t see your errors and they don’t even know what your AUT is meant to do even though it might seem perfectly obvious to you. So please relax and follow the advice below, before you start writing your post. The advice below will tell you the exact information …

> [@anuradha](#):
>
> I have tried all type of waits but it is still not working

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

---

<div class="post-metadata">

**Author:** ![anuradha](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/anuradha/32/16103_2.png) [@anuradha](https://forum.katalon.com/u/anuradha)\
**Post date:** [July 8, 2020, 1:17pm UTC](https://forum.katalon.com/t/aused-by-org-openqa-selenium-staleelementreferenceexception-stale-element-reference-element-is-not-attached-to-the-page-document/45343/6 "2020-07-08T13:17:25Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [July 8, 2020, 1:45pm UTC](https://forum.katalon.com/t/aused-by-org-openqa-selenium-staleelementreferenceexception-stale-element-reference-element-is-not-attached-to-the-page-document/45343/7 "2020-07-08T13:45:37Z")

</div>

`waitForElementClickable()` is probably not useful here.

Did you try `waitForElementVisible()` ?

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