Skip to content

Commit 0721f5c

Browse files
surliclaude
andcommitted
XWIKI-24807: AdministrationSectionPage#clickSave() doesn't wait for the page reload, causing flickering StaleElementReferenceException in administration UI tests
* clickSave(boolean) now synchronizes on the full-page reload triggered by a non-async section's save button, using the existing addPageNotYetReloadedMarker()/waitUntilPageIsReloaded() idiom, instead of returning immediately after the click * this avoids a race where a caller reading back the saved value right after clickSave() can hit a stale element from the page being unloaded Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent aca42c5 commit 0721f5c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-test/xwiki-platform-administration-test-pageobjects/src/main/java/org/xwiki/administration/test/po

xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-test/xwiki-platform-administration-test-pageobjects/src/main/java/org/xwiki/administration/test/po/AdministrationSectionPage.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,18 @@ public void clickSave(boolean wait)
145145
saveButton = getDriver().findElement(By.xpath("//input[@type='submit'][@name='action_saveandcontinue']"));
146146
} else {
147147
saveButton = getDriver().findElement(By.xpath("//input[@type='submit'][@name='formactionsac']"));
148+
// The button triggers a full page reload. Mark the current page so that we can be sure the reload has
149+
// actually happened before continuing, otherwise the caller can race the navigation and interact with
150+
// an element from the page being unloaded, causing a StaleElementReferenceException.
151+
getDriver().addPageNotYetReloadedMarker();
148152
}
149153
saveButton.click();
150154

151155
if (wait) {
152156
// Wait until the page is really saved.
153157
waitForNotificationSuccessMessage("Saved");
158+
} else if (!this.asyncSave) {
159+
getDriver().waitUntilPageIsReloaded();
154160
}
155161
}
156162

0 commit comments

Comments
 (0)