Skip to content

Commit 710e57d

Browse files
jongyoulclaude
andcommitted
[ZEPPELIN-6409] Wait for Angular paragraph output refresh via stalenessOf
The Angular paragraph re-run replaces the output DOM element. Without waiting for the old element to become stale, the test may see the old FINISHED state and try to find the new output before it exists. Fix: capture the old output element before re-run, wait for stalenessOf to confirm DOM refresh, then wait for the new element to appear. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fc68315 commit 710e57d

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

  • zeppelin-integration/src/test/java/org/apache/zeppelin/integration

zeppelin-integration/src/test/java/org/apache/zeppelin/integration/ZeppelinIT.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@
3333
import org.junit.jupiter.api.BeforeEach;
3434
import org.junit.jupiter.api.Disabled;
3535
import org.junit.jupiter.api.Test;
36+
import java.time.Duration;
3637
import org.openqa.selenium.By;
38+
import org.openqa.selenium.JavascriptExecutor;
3739
import org.openqa.selenium.Keys;
3840
import org.openqa.selenium.StaleElementReferenceException;
3941
import org.openqa.selenium.TimeoutException;
40-
import org.openqa.selenium.JavascriptExecutor;
4142
import org.openqa.selenium.WebElement;
43+
import org.openqa.selenium.support.ui.ExpectedConditions;
44+
import org.openqa.selenium.support.ui.WebDriverWait;
4245
import org.slf4j.Logger;
4346
import org.slf4j.LoggerFactory;
4447

@@ -327,22 +330,30 @@ void testAngularRunParagraph() throws Exception {
327330
"%angular <div id=\\'angularRunParagraph\\' ng-click=\\'z.runParagraph(\""
328331
+ secondParagraphId.trim()
329332
+ "\")\\'>Run second paragraph</div>");
333+
334+
// Capture old output element before re-run to detect when it gets replaced
335+
WebElement oldAngularDiv = manager.getWebDriver().findElement(By.xpath(
336+
getParagraphXPath(1) + "//div[@id=\"angularRunParagraph\"]"));
337+
330338
runParagraph(1);
339+
340+
// Wait for the old output element to become stale (proves the paragraph output
341+
// was actually refreshed, avoiding race where waitForParagraph sees the old FINISHED state)
342+
new WebDriverWait(manager.getWebDriver(), Duration.ofSeconds(MAX_BROWSER_TIMEOUT_SEC))
343+
.until(ExpectedConditions.stalenessOf(oldAngularDiv));
344+
331345
waitForParagraph(1, "FINISHED");
332346

333-
// Wait for Angular to re-render the output with ng-click binding
334-
waitForText("Run second paragraph", By.xpath(
335-
getParagraphXPath(1) + "//div[@id=\"angularRunParagraph\"]"));
347+
// Wait for new Angular output to render
348+
WebElement newAngularDiv = visibilityWait(By.xpath(
349+
getParagraphXPath(1) + "//div[@id=\"angularRunParagraph\"]"), MAX_BROWSER_TIMEOUT_SEC);
336350

337351
// Set new text value for 2nd paragraph
338352
setTextOfParagraph(2, "%sh echo NEW_VALUE");
339353

340354
// Click on Angular-rendered div to trigger z.runParagraph() function.
341-
// Use JavaScript click because Angular-compiled ng-click elements may not be
342-
// considered "clickable" by Selenium's native click (overlay/stale issues).
343-
WebElement angularDiv = visibilityWait(By.xpath(
344-
getParagraphXPath(1) + "//div[@id=\"angularRunParagraph\"]"), MAX_BROWSER_TIMEOUT_SEC);
345-
((JavascriptExecutor) manager.getWebDriver()).executeScript("arguments[0].click();", angularDiv);
355+
// Use JavaScript click to bypass overlay/clickability issues with ng-click elements.
356+
((JavascriptExecutor) manager.getWebDriver()).executeScript("arguments[0].click();", newAngularDiv);
346357
ZeppelinITUtils.sleep(1000, false);
347358

348359
waitForParagraph(2, "FINISHED");

0 commit comments

Comments
 (0)