SeleniumHQ / selenium-ide

Open Source record and playback test automation for the web.
https://selenium.dev/selenium-ide/
Apache License 2.0
2.8k stars 762 forks source link

stale element reference: stale element not found #1824

Closed andyp05 closed 4 months ago

andyp05 commented 4 months ago

🐛 Bug Report

Running on Windows 11, 4.0.1 Beta 10.

If I run the test script using the Chrome plugin 3.17.2, the VerifyText works fine. If I run using the latest IDE, I get

5:08:55 PM [info] [
  "api: 'Dispatch event' 'playback.onStepUpdate' [\n" +
    '  {\n' +
    "    id: '302b27a9-df1c-4c66-9580-9daa29c6bb50',\n" +
    '    callstackIndex: 0,\n' +
    '    command: {\n' +
    "      id: '302b27a9-df1c-4c66-9580-9daa29c6bb50',\n" +
    "      comment: '',\n" +
    "      command: 'verifyText',\n" +
    "      target: 'css=#data-table > tbody > tr > td',\n" +
    '      targets: [Array],\n' +
    "      value: 'No data to display.'\n" +
    '    },\n' +
    "    state: 'errored',\n" +
    "    message: 'stale element reference: stale element not found\\n' +\n" +
    "      '  (Session info: chrome=120.0.6099.227) during verifyText:css=#data-table > tbody > tr > td:No data to display.',\n" +
    '    error: T: stale element reference: stale element not found\n' +
    '      (Session info: chrome=120.0.6099.227) during verifyText:css=#-data-table > tbody > tr > td:No data to display.\n' +
    '        at Object.throwDecodedError (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\node_modules\\.pnpm\\selenium-webdriver@4.20.0\\node_modules\\selenium-webdriver\\lib\\error.js:521:15)\n' +
    '        at parseHttpResponse (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\node_modules\\.pnpm\\selenium-webdriver@4.20.0\\node_modules\\selenium-webdriver\\lib\\http.js:514:13)\n' +
    '        at Executor.execute (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\node_modules\\.pnpm\\selenium-webdriver@4.20.0\\node_modules\\selenium-webdriver\\lib\\http.js:446:28)\n' +
    '        at process.this (node:internal/process/task_queues:95:5)\n' +
    '        at l.text [as execute] (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\node_modules\\.pnpm\\selenium-webdriver@4.20.0\\node_modules\\selenium-webdriver\\lib\\webdriver.js:741:26)\n' +
    '        at g.doAssertText (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\side-runtime\\src\\webdriver.ts:1219:11)\n' +
    '        at g.doVerifyText (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\side-runtime\\src\\webdriver.ts:1914:13)\n' +
    '        at t.CommandNode.result [as _executeCommand] (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\side-runtime\\src\\playback-tree\\command-node.ts:152:11)\n' +
    '        at t.CommandNode.execute (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\side-runtime\\src\\playback-tree\\command-node.ts:112:11)\n' +
    '        at t.default.result [as _executeCommand] (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\side-runtime\\src\\playback.ts:562:7)\n' +
    '        at t.default.next [as _executionLoop] (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\side-runtime\\src\\playback.ts:438:9)\n' +
    '        at t.default.next [as _executionLoop] (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\side-runtime\\src\\playback.ts:493:42)\n' +
    '        at t.default.next [as _executionLoop] (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\side-runtime\\src\\playback.ts:493:42)\n' +
    '        at t.default.next [as _executionLoop] (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\side-runtime\\src\\playback.ts:493:42)\n' +
    '        at t.default.next [as _executionLoop] (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\side-runtime\\src\\playback.ts:493:42)\n' +
    '        at t.default._executionLoop (C:\\Program Files\\Selenium IDE\\resources\\app.asar\\build\\webpack:\\side-runtime\\src\\playback.ts:493:42) {\n' +
    "      remoteStacktrace: '\\tGetHandleVerifier [0x00007FF7A5FF9D32+60162]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5F4A3E2]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5DB76ED]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5DBCF0A]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5DBF23B]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5DBF330]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5DFB0FE]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5E2584A]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5DF5A86]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5E25D10]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5E42445]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5E255F3]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5DF416D]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5DF5214]\\n' +\n" +
    "        '\\tCr_z_adler32 [0x00007FF7A64122FB+290059]\\n' +\n" +
    "        '\\tCr_z_adler32 [0x00007FF7A6469B67+648567]\\n' +\n" +
    "        '\\tCr_z_adler32 [0x00007FF7A6461933+615235]\\n' +\n" +
    "        '\\tGetHandleVerifier [0x00007FF7A60B33C9+819609]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5F561F8]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5F51174]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5F512EC]\\n' +\n" +
    "        '\\t(No symbol) [0x00007FF7A5F417D4]\\n' +\n" +
    "        '\\tBaseThreadInitThunk [0x00007FFF1C911FD7+23]\\n' +\n" +
    "        '\\tRtlUserThreadStart [0x00007FFF1D9FD7D0+32]\\n'\n" +
    '    },\n' +
    "    testID: '7cadcc2a-6aad-4d97-bfcf-81e32cd2c0d9'\n" +
    '  }\n' +
    ']'
]

The text I am looking for is a message generated by a datatable after an AJAX call. The call takes < 150ms. The message stays on the screen indefinitely.

The first 20 lines of the test script run fine. If I use the 'select element' function and reselect the text in the browser, it still fails.

To Reproduce

Create a page and have a DataTable from https://datatables.net on it and make an AJAX call that returns no data.

Expected behavior

VerifyText to look at the message and return successfully and without error. The browser plugin running the same .side file returns successfully.

Project file reproducing this issue (highly encouraged)

{
      "id": "302b27a9-df1c-4c66-9580-9daa29c6bb50",
      "comment": "",
      "command": "verifyText",
      "target": "css=#data-table > tbody > tr > td",
      "targets": [
        ["css=#data-table .dataTables_empty", "css:finder"],
        ["xpath=//table[@id='data-table']/tbody/tr/td", "xpath:idRelative"],
        ["xpath=//td", "xpath:position"],
        ["xpath=//td[contains(.,'No data to display.')]", "xpath:innerText"]
      ],
      "value": "No data to display."
    }

Environment

OS: Windows 11 Selenium IDE Version: 4.0.1 beta 10

[
  'Starting driver',
  'electron',
  'at',
  'C:\\Program Files\\Selenium IDE\\resources\\app.asar.unpacked\\node_modules\\electron-chromedriver\\bin\\chromedriver.exe',
  'with args',
  '--verbose --port=9516'
]
toddtarsi commented 4 months ago

@andyp05 - For my own personal interest, do you primarily use code-export? I'm always interested in the pain points of people who have code export workflows.

I think in v3 browser, there may be some level of durability that doesn't exist here. I'd recommend swapping this command for waitForText in v4, which has a lot more durability built into it. In my mind, this is how the variants of the commands work (feel free to correct me because idk why there are three variants of this command in the first place):

andyp05 commented 4 months ago

Replaced 'Verify Text' with 'Wait for text' and it worked. Thanks for your help.

github-actions[bot] commented 3 months ago

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.