Skip to content

Conversation

@niklasmohrin
Copy link
Member

@niklasmohrin niklasmohrin commented Jul 31, 2025

We noticed test failures in CI:

selenium.common.exceptions.StaleElementReferenceException: Message: The element with the reference b70abd94-a473-4dad-ad6f-a8629a9007ae is stale; either its node document is not the active document, or it is no longer connected to the DOM; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#staleelementreferenceexception

on the line

checkbox = row.find_element(By.CSS_SELECTOR, "input[type=radio][value='2'] + label.choice-error")

From the documentation, it seems that the row variable becomes stale. This can occur if the browser is slow and the page reload only happens after we assigned the row variable initially. To fix this, I inserted a wait command that ensures that the page has reloaded. The other tests in this file don't seem to submit the form, so they should be fine.

Note that the CI failure can be reproduced by moving the row = line before the submit_button.click() call.

@niklasmohrin niklasmohrin merged commit a4a9391 into e-valuation:main Aug 1, 2025
15 checks passed
@niklasmohrin niklasmohrin deleted the fix-flaky-selenium branch August 1, 2025 13:08
styrix560 pushed a commit to styrix560/EvaP that referenced this pull request Aug 4, 2025
…rning` (e-valuation#2492)

We noticed test failures in CI:

```plain
selenium.common.exceptions.StaleElementReferenceException: Message: The element with the reference b70abd94-a473-4dad-ad6f-a8629a9007ae is stale; either its node document is not the active document, or it is no longer connected to the DOM; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#staleelementreferenceexception
```

on the line

```python
checkbox = row.find_element(By.CSS_SELECTOR, "input[type=radio][value='2'] + label.choice-error")
```

From the documentation, it seems that the `row` variable becomes stale. This can occur if the browser is slow and the page reload only happens after we assigned the `row` variable initially. To fix this, I inserted a wait command that ensures that the page has reloaded. The other tests in this file don't seem to submit the form, so they should be fine.

Note that the CI failure can be reproduced by moving the `row = ` line before the `submit_button.click()` call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants