Skip to content

[e2e]: Fix flaky ElementClickInterceptedException in System and Resource pages#4337

Open
limc5462 wants to merge 2 commits intoapache:devfrom
limc5462:fix/flaky-e2e-test
Open

[e2e]: Fix flaky ElementClickInterceptedException in System and Resource pages#4337
limc5462 wants to merge 2 commits intoapache:devfrom
limc5462:fix/flaky-e2e-test

Conversation

@limc5462
Copy link
Contributor

…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 UserManagementTest and UploadManagementTest where 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: Added Thread.sleep() before all menu.click() actions with @SneakyThrows to fix ElementClickInterceptedException caused 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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 submenu click() actions in SystemPage and ResourcePage.
  • Annotates goToTab(...) with Lombok @SneakyThrows to avoid handling InterruptedException.

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.

Comment on lines +54 to 60
@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();
Copy link

Copilot AI Mar 23, 2026

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. 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.

Copilot uses AI. Check for mistakes.
Comment on lines +54 to 60
@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();
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copilot uses AI. Check for mistakes.
Comment on lines +48 to 54
@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();
Copy link

Copilot AI Mar 23, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +48 to 54
@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();
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
image

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants