From 7d6eff76962fdf70fee486f4f071b93ec4a8acf5 Mon Sep 17 00:00:00 2001 From: GnsP Date: Thu, 24 Oct 2024 11:14:59 +0530 Subject: [PATCH] try to close the alert only if it's present --- .../cdap/cdap/ui/stepsdesign/WidgetCodeEditor.java | 4 ++-- .../java/io/cdap/cdap/ui/utils/Commands.java | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/e2e-test/java/io/cdap/cdap/ui/stepsdesign/WidgetCodeEditor.java b/src/e2e-test/java/io/cdap/cdap/ui/stepsdesign/WidgetCodeEditor.java index f50b27c50dc..35b88f594b5 100644 --- a/src/e2e-test/java/io/cdap/cdap/ui/stepsdesign/WidgetCodeEditor.java +++ b/src/e2e-test/java/io/cdap/cdap/ui/stepsdesign/WidgetCodeEditor.java @@ -65,8 +65,8 @@ public void verifyDefaultJSEditorValue() { WebElement jsEditorContentElement = jsEditorElement.findElement( By.cssSelector("div[class*='ace_text-layer']")); String editorValue = ElementHelper.getElementText(jsEditorContentElement); - Assert.assertEquals(StringUtils.normalizeSpace(editorValue), - StringUtils.normalizeSpace(defaultJsEditorVal)); + Assert.assertEquals(defaultJsEditorVal.replaceAll("\\s+", ""), + editorValue.replaceAll("\\s+", "")); } @Then("Replace and verify JS editor value and cursor position") diff --git a/src/e2e-test/java/io/cdap/cdap/ui/utils/Commands.java b/src/e2e-test/java/io/cdap/cdap/ui/utils/Commands.java index bae36123a49..2affb74f64e 100644 --- a/src/e2e-test/java/io/cdap/cdap/ui/utils/Commands.java +++ b/src/e2e-test/java/io/cdap/cdap/ui/utils/Commands.java @@ -30,6 +30,7 @@ import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.openqa.selenium.By; +import org.openqa.selenium.NoAlertPresentException; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.OutputType; import org.openqa.selenium.StaleElementReferenceException; @@ -183,7 +184,11 @@ public static void fillConnectionCreateForm(String connectionType, String connec } public static void dismissStudioLeaveConfirmationModal() { - SeleniumDriver.getDriver().switchTo().alert().accept(); + try { + SeleniumDriver.getDriver().switchTo().alert().accept(); + } catch (NoAlertPresentException e) { + // ignore it. + } } public static void openPluginGroupPanel(String pluginGroup) { @@ -354,8 +359,10 @@ public static void fillInPipelineName(String pipelineName) { public static void dismissTopBanner() { try { - ElementHelper.clickOnElement(Helper.locateElementByXPath( - "//div[@data-testid='valium-banner-hydrator']//button[@class='close ng-scope']")); + WebElement bannerCloseButton = Helper.locateElementByXPath( + "//div[@data-testid='valium-banner-hydrator']//button[@class='close ng-scope']"); + WaitHelper.waitForElementToBeClickable(bannerCloseButton, 180L); + ElementHelper.clickOnElement(bannerCloseButton); } catch (NoSuchElementException e) { // pass }