[e2e]: Fix flaky ElementClickInterceptedException in System and Resource pages#4337
[e2e]: Fix flaky ElementClickInterceptedException in System and Resource pages#4337limc5462 wants to merge 2 commits intoapache:devfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Stabilizes StreamPark E2E navigation on System and Resource pages by reducing click interception during UI expand/collapse animations.
Changes:
- Adds a new UI-animation delay constant (
DEFAULT_UI_ANIMATION_SLEEP_MILLISECONDS). - Inserts a fixed
Thread.sleep(...)before submenuclick()actions inSystemPageandResourcePage. - Annotates
goToTab(...)with Lombok@SneakyThrowsto avoid handlingInterruptedException.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/system/SystemPage.java |
Adds fixed sleep before submenu clicks in goToTab and uses @SneakyThrows. |
streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/resource/ResourcePage.java |
Adds fixed sleep before submenu clicks in goToTab and uses @SneakyThrows. |
streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/common/Constants.java |
Introduces DEFAULT_UI_ANIMATION_SLEEP_MILLISECONDS used by page navigation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @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_UI_ANIMATION_SLEEP_MILLISECONDS); | ||
| menuUserManagement.click(); |
There was a problem hiding this comment.
Using a fixed Thread.sleep before clicking will slow every navigation and can still be flaky on slower/faster environments. Since NavBarPage already detects expanded menus via the streampark-menu-opened class, prefer an explicit WebDriverWait for the System menu to be in the opened/expanded state (or retry the click until it succeeds) instead of a hard-coded sleep.
| @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_UI_ANIMATION_SLEEP_MILLISECONDS); | ||
| menuUserManagement.click(); |
There was a problem hiding this comment.
@SneakyThrows around Thread.sleep will propagate InterruptedException as an unchecked exception and also clears the interrupt flag. Please catch InterruptedException explicitly here, call Thread.currentThread().interrupt(), and then fail fast (e.g., rethrow a RuntimeException) so test interruptions/shutdowns behave correctly.
| @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_UI_ANIMATION_SLEEP_MILLISECONDS); | ||
| menuVariables.click(); |
There was a problem hiding this comment.
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.
| @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_UI_ANIMATION_SLEEP_MILLISECONDS); | ||
| menuVariables.click(); |
There was a problem hiding this comment.
@SneakyThrows around Thread.sleep will propagate InterruptedException as an unchecked exception and also clears the interrupt flag. Please catch InterruptedException explicitly here, call Thread.currentThread().interrupt(), and then fail fast so test interruptions/shutdowns behave correctly.
There was a problem hiding this comment.
@wolfboys This sleep pattern (@SneakyThrows + Thread.sleep(DEFAULT_SLEEP_MILLISECONDS)) is already used in 21 places across the e2e module. My code follows the same convention — sleeping 2000ms after clicking a dropdown to wait for options to render, identical to ApplicationForm.flinkCluster() and UploadsPage. Modifying all existing occurrences would be too invasive; I suggest keeping the current approach consistent.
Like this

|



…source pages
What changes were proposed in this pull request
This PR addresses a critical stability issue (flaky tests) in the E2E testing pipeline for StreamPark.
Fix Flaky UI Tests (
ElementClickInterceptedException):A race condition frequently occurred in
UserManagementTestandUploadManagementTestwhere the Selenium webdriver clicked on child menu items while the parent menu's CSS expanding animation was still in progress. This caused clicks to be intercepted by the animated mask or parent container.Brief change log
SystemPage.java&ResourcePage.java: AddedThread.sleep()before allmenu.click()actions with@SneakyThrowsto fixElementClickInterceptedExceptioncaused by CSS animations.Verifying this change
This is the last E2E issue I've found. From now on, the pipeline is highly likely to run successfully every time.
Does this pull request potentially affect one of the following parts
no