From 72d29971bfe805ab7c7f23e692c88083aa3b8989 Mon Sep 17 00:00:00 2001 From: xiangzihao <460888207@qq.com> Date: Thu, 21 Jul 2022 15:43:24 +0800 Subject: [PATCH] [E2E] [CI] Fix flaky e2e test (#11077) * fix flaky e2e test * fix flaky e2e test * fix flaky e2e test --- .../dolphinscheduler/e2e/pages/common/NavBarPage.java | 4 ++-- .../e2e/pages/datasource/DataSourcePage.java | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/NavBarPage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/NavBarPage.java index 1635ef73d9..0c846a24c4 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/NavBarPage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/NavBarPage.java @@ -17,6 +17,7 @@ * under the License. * */ + package org.apache.dolphinscheduler.e2e.pages.common; import org.apache.dolphinscheduler.e2e.pages.datasource.DataSourcePage; @@ -28,7 +29,6 @@ import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.FindBy; -import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; @@ -75,7 +75,7 @@ public class NavBarPage { if (nav == ResourcePage.class) { new WebDriverWait(driver, 60).until(ExpectedConditions.elementToBeClickable(resourceTab)); - resourceTab.click(); + ((JavascriptExecutor) driver).executeScript("arguments[0].click();", resourceTab()); return nav.cast(new ResourcePage(driver)); } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/datasource/DataSourcePage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/datasource/DataSourcePage.java index 2e479fd019..210b588895 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/datasource/DataSourcePage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/datasource/DataSourcePage.java @@ -30,11 +30,13 @@ import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; @@ -66,10 +68,12 @@ public class DataSourcePage extends NavBarPage implements NavBarPage.NavBarItem String jdbcParams) { buttonCreateDataSource().click(); + new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated( + new By.ByClassName("dialog-create-data-source"))); + createDataSourceForm().btnDataSourceTypeDropdown().click(); - new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated( - new By.ByClassName("dialog-create-data-source"))); + new WebDriverWait(driver, 10).until(ExpectedConditions.textToBePresentInElement(driver.findElement(By.className("dialog-create-data-source")), dataSourceType.toUpperCase())); createDataSourceForm().selectDataSourceType() .stream()