Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,38 @@ protected void authenticationUser(String userName, String password) {
By.xpath("//*[@id='loginModalContent']//button[contains(.,'Login')]"),
MAX_BROWSER_TIMEOUT_SEC).click();

ZeppelinITUtils.sleep(1000, false);
// Wait for the logged-in navbar user dropdown to appear (indicates login completed
// and Angular digest cycle has updated the DOM), then dismiss any leftover modal overlay
visibilityWait(
By.xpath("//div[contains(@class, 'navbar-collapse')]//li//button[contains(@class, 'nav-btn dropdown-toggle ng-scope')]"),
MAX_BROWSER_TIMEOUT_SEC);
try {
((JavascriptExecutor) manager.getWebDriver()).executeScript(
"$('.modal-backdrop').remove(); $('#loginModal').modal('hide');");
} catch (Exception e) {
// ignore if jQuery/Bootstrap not ready
}
ZeppelinITUtils.sleep(500, false);
}

protected void logoutUser(String userName) throws URISyntaxException {
ZeppelinITUtils.sleep(500, false);
manager.getWebDriver().findElement(
By.xpath("//div[contains(@class, 'navbar-collapse')]//li[contains(.,'" + userName + "')]")).click();
clickableWait(
By.xpath("//div[contains(@class, 'navbar-collapse')]//li[contains(.,'" + userName + "')]"),
MAX_BROWSER_TIMEOUT_SEC).click();
ZeppelinITUtils.sleep(500, false);
manager.getWebDriver().findElement(
By.xpath("//div[contains(@class, 'navbar-collapse')]//li[contains(.,'" + userName + "')]//a[@ng-click='navbar.logout()']")).click();
clickableWait(
By.xpath("//div[contains(@class, 'navbar-collapse')]//li[contains(.,'" + userName + "')]//a[@ng-click='navbar.logout()']"),
MAX_BROWSER_TIMEOUT_SEC).click();
ZeppelinITUtils.sleep(2000, false);
if (manager.getWebDriver().findElement(
By.xpath("//*[@id='loginModal']//div[contains(@class, 'modal-header')]/button")).isDisplayed()) {
manager.getWebDriver().findElement(
By.xpath("//*[@id='loginModal']//div[contains(@class, 'modal-header')]/button")).click();
try {
WebElement closeButton = manager.getWebDriver().findElement(
By.xpath("//*[@id='loginModal']//div[contains(@class, 'modal-header')]/button"));
if (closeButton.isDisplayed()) {
closeButton.click();
}
} catch (NoSuchElementException e) {
// login modal close button not found, which is fine
}
manager.getWebDriver().get(new URI(manager.getWebDriver().getCurrentUrl()).resolve("/classic/#/").toString());
ZeppelinITUtils.sleep(500, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -326,16 +330,31 @@ void testAngularRunParagraph() throws Exception {
"%angular <div id=\\'angularRunParagraph\\' ng-click=\\'z.runParagraph(\""
+ secondParagraphId.trim()
+ "\")\\'>Run second paragraph</div>");

// Capture old output element before re-run to detect when it gets replaced
WebElement oldAngularDiv = manager.getWebDriver().findElement(By.xpath(
getParagraphXPath(1) + "//div[@id=\"angularRunParagraph\"]"));

runParagraph(1);

// Wait for the old output element to become stale (proves the paragraph output
// was actually refreshed, avoiding race where waitForParagraph sees the old FINISHED state)
new WebDriverWait(manager.getWebDriver(), Duration.ofSeconds(MAX_BROWSER_TIMEOUT_SEC))
.until(ExpectedConditions.stalenessOf(oldAngularDiv));

waitForParagraph(1, "FINISHED");

// Wait for new Angular output to render
WebElement newAngularDiv = visibilityWait(By.xpath(
getParagraphXPath(1) + "//div[@id=\"angularRunParagraph\"]"), MAX_BROWSER_TIMEOUT_SEC);

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

// Click on 1 paragraph to trigger z.runParagraph() function

// Click on Angular-rendered div to trigger z.runParagraph() function.
// Use JavaScript click to bypass overlay/clickability issues with ng-click elements.
((JavascriptExecutor) manager.getWebDriver()).executeScript("arguments[0].click();", newAngularDiv);
ZeppelinITUtils.sleep(1000, false);
clickAndWait(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularRunParagraph\"]"));

waitForParagraph(2, "FINISHED");

Expand Down
Loading