0

I'm writing a test suite using Atata and am receiving this exception "Selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document" trying to iterate over all the <tr> elements in a <table>'s <tbody> element.

The issue appears to be rooted in the DataTables jQuery library being used in the web app being tested; everytime the 'draw()' method is invoked on the client/JavaScript side, it removes all <tr> and their enclosing <td> elements and re-creates them. This means the test only works for the very first <tr>.

Basically with each <tr>, my test clicks a button in each table row that causes DataTables.js to re-draw the entire table each time; the only thing that changes between each re-draw is 2 CSS classes get modified on the current <tr> element:

Before button click:

<tr class="bringup-overdue reminder odd" role="row">

After button click:

<tr class="bringup-completed d-none reminder odd" role="row">

The number of rows remains the same after each re-draw, and except for the CSS class changes, all the HTML code for the table remains exactly the same, but because all existing DOM-references have been lost, the "Selenium.StaleElementReferenceException" exception keeps happening. The re-draw is an AJAX operation, not a full page reload.

Is there any way to get Atata to simply refresh all of its internal references to those newly-re-created elements? I know from working directly with the Selenium API, you can simply re-try calling 'FindElement', like in this answer here, but I can't seem to find an equivalent Atata API for that.

mamift
  • 651
  • 7
  • 18
  • Could you please share parts of your C# code of page object and test. We need to see how you interact with a table. – Yevgeniy Shunevych Jan 19 '22 at 12:38
  • OK I will need to edit the code to clear out some elements confidential to my employer. But in the meantime, speaking generally, do you know if it's possible for Atata to retry or recover from this type of exception? – mamift Jan 20 '22 at 03:15

0 Answers0