-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[e2e]: Fix flaky ElementClickInterceptedException in System and Resource pages #4337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import org.apache.streampark.e2e.pages.common.NavBarPage.NavBarItem; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.SneakyThrows; | ||
| import org.openqa.selenium.WebElement; | ||
| import org.openqa.selenium.remote.RemoteWebDriver; | ||
| import org.openqa.selenium.support.FindBy; | ||
|
|
@@ -44,24 +45,28 @@ | |
| super(driver); | ||
| } | ||
|
|
||
| @SneakyThrows | ||
| public <T extends ResourcePage.Tab> T goToTab(Class<T> tab) { | ||
| if (tab == VariablesPage.class) { | ||
| new WebDriverWait(driver, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION) | ||
| .until(ExpectedConditions.elementToBeClickable(menuVariables)); | ||
| Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS); | ||
|
Check warning on line 53 in streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/resource/ResourcePage.java
|
||
| menuVariables.click(); | ||
|
Comment on lines
+48
to
54
|
||
| return tab.cast(new VariablesPage(driver)); | ||
| } | ||
|
|
||
| if (tab == ProjectsPage.class) { | ||
| new WebDriverWait(driver, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION) | ||
| .until(ExpectedConditions.elementToBeClickable(menuProjects)); | ||
| Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS); | ||
|
Check warning on line 61 in streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/resource/ResourcePage.java
|
||
| menuProjects.click(); | ||
| return tab.cast(new ProjectsPage(driver)); | ||
| } | ||
|
|
||
| if (tab == UploadsPage.class) { | ||
| new WebDriverWait(driver, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION) | ||
| .until(ExpectedConditions.elementToBeClickable(menuUploads)); | ||
| Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS); | ||
|
Check warning on line 69 in streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/resource/ResourcePage.java
|
||
| menuUploads.click(); | ||
| return tab.cast(new UploadsPage(driver)); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import org.apache.streampark.e2e.pages.common.NavBarPage.NavBarItem; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.SneakyThrows; | ||
| import org.openqa.selenium.WebElement; | ||
| import org.openqa.selenium.remote.RemoteWebDriver; | ||
| import org.openqa.selenium.support.FindBy; | ||
|
|
@@ -50,37 +51,43 @@ | |
| super(driver); | ||
| } | ||
|
|
||
| @SneakyThrows | ||
| public <T extends SystemPage.Tab> T goToTab(Class<T> tab) { | ||
| if (tab == UserManagementPage.class) { | ||
| new WebDriverWait(driver, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION) | ||
| .until(ExpectedConditions.elementToBeClickable(menuUserManagement)); | ||
| Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS); | ||
|
Check warning on line 59 in streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/system/SystemPage.java
|
||
| menuUserManagement.click(); | ||
|
Comment on lines
+54
to
60
|
||
| return tab.cast(new UserManagementPage(driver)); | ||
| } | ||
|
|
||
| if (tab == TeamManagementPage.class) { | ||
| new WebDriverWait(driver, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION) | ||
| .until(ExpectedConditions.elementToBeClickable(menuTeamManagement)); | ||
| Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS); | ||
|
Check warning on line 67 in streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/system/SystemPage.java
|
||
| menuTeamManagement.click(); | ||
| return tab.cast(new TeamManagementPage(driver)); | ||
| } | ||
|
|
||
| if (tab == RoleManagementPage.class) { | ||
| new WebDriverWait(driver, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION) | ||
| .until(ExpectedConditions.elementToBeClickable(menuRoleManagement)); | ||
| Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS); | ||
|
Check warning on line 75 in streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/system/SystemPage.java
|
||
| menuRoleManagement.click(); | ||
| return tab.cast(new RoleManagementPage(driver)); | ||
| } | ||
| if (tab == TokenManagementPage.class) { | ||
| new WebDriverWait(driver, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION) | ||
| .until(ExpectedConditions.elementToBeClickable(menuTokenManagement)); | ||
| Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS); | ||
|
Check warning on line 82 in streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/system/SystemPage.java
|
||
| menuTokenManagement.click(); | ||
| return tab.cast(new TokenManagementPage(driver)); | ||
| } | ||
|
|
||
| if (tab == MemberManagementPage.class) { | ||
| new WebDriverWait(driver, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION) | ||
| .until(ExpectedConditions.elementToBeClickable(menuMemberManagement)); | ||
| Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS); | ||
|
Check warning on line 90 in streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/system/SystemPage.java
|
||
| menuMemberManagement.click(); | ||
| return tab.cast(new MemberManagementPage(driver)); | ||
| } | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a fixed Thread.sleep before clicking will slow every navigation and can still be flaky on slower/faster environments. Prefer waiting on a deterministic condition (e.g., the Resource menu container has the expected "opened" class / submenu is fully expanded, or retry click until not intercepted) rather than a hard-coded sleep.