Skip to content

Commit

Permalink
Merge pull request #1262 from GnsP/fix-flaky-e2e-tests
Browse files Browse the repository at this point in the history
[🍒][6.10] cherrypick part of #1250
  • Loading branch information
GnsP authored Nov 26, 2024
2 parents a2f1d13 + 7d6eff7 commit a36d9b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
13 changes: 10 additions & 3 deletions src/e2e-test/java/io/cdap/cdap/ui/utils/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit a36d9b0

Please sign in to comment.