Skip to content

Commit 9a42dbf

Browse files
jongyoulclaude
andcommitted
fix(integration): fix login race condition in Selenium integration tests
The Selenium test InterpreterModeActionsIT.testPerUserIsolatedAction fails intermittently due to two race conditions: 1. sendKeys may not complete before the login button is clicked, causing the server to receive a null username. Fixed by clearing the field first and verifying the value is non-empty before submit. 2. The login modal overlay remains visible after authentication, causing ElementClickInterceptedException. Fixed by explicitly waiting for modal invisibility and removing backdrop via JS. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 33214d4 commit 9a42dbf

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,36 @@ protected void authenticationUser(String userName, String password) {
5555
By.xpath("//div[contains(@class, 'navbar-collapse')]//li//button[contains(.,'Login')]"),
5656
MAX_BROWSER_TIMEOUT_SEC).click();
5757

58-
visibilityWait(By.xpath("//*[@id='userName']"), MAX_BROWSER_TIMEOUT_SEC).sendKeys(userName);
59-
visibilityWait(By.xpath("//*[@id='password']"), MAX_BROWSER_TIMEOUT_SEC).sendKeys(password);
58+
WebElement userNameField = visibilityWait(By.xpath("//*[@id='userName']"), MAX_BROWSER_TIMEOUT_SEC);
59+
userNameField.clear();
60+
userNameField.sendKeys(userName);
61+
62+
WebElement passwordField = visibilityWait(By.xpath("//*[@id='password']"), MAX_BROWSER_TIMEOUT_SEC);
63+
passwordField.clear();
64+
passwordField.sendKeys(password);
65+
66+
// Verify credentials were entered before submitting
67+
WebDriverWait fieldWait = new WebDriverWait(manager.getWebDriver(), Duration.ofSeconds(5));
68+
fieldWait.until(driver -> !driver.findElement(By.xpath("//*[@id='userName']"))
69+
.getAttribute("value").isEmpty());
70+
6071
clickableWait(
6172
By.xpath("//*[@id='loginModalContent']//button[contains(.,'Login')]"),
6273
MAX_BROWSER_TIMEOUT_SEC).click();
6374

64-
ZeppelinITUtils.sleep(1000, false);
75+
// Wait for the login modal to fully close before interacting with other elements
76+
WebDriverWait wait = new WebDriverWait(manager.getWebDriver(),
77+
Duration.ofSeconds(MAX_BROWSER_TIMEOUT_SEC));
78+
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("loginModal")));
79+
80+
// Dismiss any lingering modal backdrop via JavaScript
81+
try {
82+
((JavascriptExecutor) manager.getWebDriver()).executeScript(
83+
"document.querySelectorAll('.modal-backdrop').forEach(e => e.remove());");
84+
} catch (Exception e) {
85+
// ignore if not ready
86+
}
87+
ZeppelinITUtils.sleep(500, false);
6588
}
6689

6790
protected void logoutUser(String userName) throws URISyntaxException {

0 commit comments

Comments
 (0)