Skip to content

Commit f08993c

Browse files
committed
[Misc] Fix unhandled StaleElementReferenceException on LiveDataElement.waitUntilReady
1 parent baf793e commit f08993c

File tree

1 file changed

+13
-2
lines changed
  • xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-test/xwiki-platform-livedata-test-pageobjects/src/main/java/org/xwiki/livedata/test/po

1 file changed

+13
-2
lines changed

xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-test/xwiki-platform-livedata-test-pageobjects/src/main/java/org/xwiki/livedata/test/po/LiveDataElement.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.util.Arrays;
2323

2424
import org.openqa.selenium.By;
25+
import org.openqa.selenium.NoSuchElementException;
26+
import org.openqa.selenium.StaleElementReferenceException;
2527
import org.xwiki.test.ui.po.BaseElement;
2628

2729
/**
@@ -72,8 +74,17 @@ private void waitUntilReady()
7274
// This div is replaced by the Live Data Vue template once vue is loaded.
7375
getDriver().waitUntilCondition(
7476
input -> {
75-
String[] classes = getDriver().findElement(By.id(this.id)).getAttribute("class").split("\\s+");
76-
return !Arrays.asList(classes).contains("loading");
77+
try {
78+
String[] classes =
79+
getDriver().findElementWithoutWaiting(By.id(this.id)).getAttribute("class")
80+
.split("\\s+");
81+
return !Arrays.asList(classes).contains("loading");
82+
} catch (NoSuchElementException | StaleElementReferenceException e) {
83+
// If there is no such element that mean the Live data is not loaded yet (or is missing).
84+
// If the element is stale, that means the element was removed from the DOM in the meantime, because
85+
// the initial div produced by the live data macro was replaced by the Vue template.
86+
return false;
87+
}
7788
});
7889

7990
// Then, once the Vue template is loaded, a div with the loading class is inserted until the rest of the data

0 commit comments

Comments
 (0)