Title
Unstable file upload and resource selection issues in Selenium Java-based workflow tests for DolphinScheduler
Question Description
Background:
I am performing end-to-end (E2E) automated tests on Apache DolphinScheduler using Selenium WebDriver with Java. The DolphinScheduler (ds) system is running on Java 8, and the E2E tests are running on Java 11. The test environment itself is functioning normally.
My tests include operations like uploading JAR files and selecting multiple resource files within the DolphinScheduler UI. However, I am encountering two main issues:
- Uploading
normal1.jar
is unstable: The file upload dialog appears, but the upload button is often not clicked, resulting in the file not being uploaded successfully. - Unable to select multiple resource files: When clicking the resource file dropdown, the files are displayed normally, but I'm often unable to click and select the corresponding files.
Problem Details:
Issue with File Upload:
- During the upload process, the file upload dialog opens, but the automation script doesn't consistently click the upload button.
- I have implemented
WebDriverWait
to ensure elements are loaded before interacting, but the issue persists intermittently.
Issue with Selecting Multiple Resource Files:
- The resource files are visible in the dropdown or selection box.
- Clicking on the files does not result in them being selected
Relevant Code:
//test class
void testCreateNormalJarWorkflow() {
FileManagePage file = new NavBarPage(browser)
.goToNav(ResourcePage.class)
.goToTab(FileManagePage.class)
.delete("fat.jar")
.uploadFile(filePath + "/normal2.jar");
WebDriverWait wait = WebDriverWaitFactory.createWebDriverWait(browser);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='normal2.jar']")));
file.uploadFile(filePath + "/normal1.jar");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='normal1.jar']")));
ProjectPage projectPage = new NavBarPage(browser)
.goToNav(ProjectPage.class);
wait.until(ExpectedConditions.visibilityOfAllElements(projectPage.projectList()));
WorkflowDefinitionTab workflowDefinitionPage = projectPage
.goTo(project)
.goToTab(WorkflowDefinitionTab.class);
workflowDefinitionPage.createWorkflow()
.<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
.selectRunType("NORMAL_JAR")
.selectMainPackage("normal1.jar")
.selectResource("normal1.jar")
.selectResource("normal1.jar")
.selectResource("normal2.jar")
.name("test-2")
.selectEnv(environmentName)
.submit()
.submit()
.name(workflow2)
.submit();
Awaitility.await().untilAsserted(() -> assertThat(workflowDefinitionPage.workflowList())
.as("Workflow list should contain newly-created workflow")
.anyMatch(it -> it.getText().contains(workflow2)));
workflowDefinitionPage.publish(workflow2);
}
//selectResource
@FindBys({
@FindBy(className = "resource-select"),
@FindBy(className = "n-base-selection"),
})
private WebElement selectResource;
public TaskNodeForm selectResource(String resourceName) {
((JavascriptExecutor) parent().driver()).executeScript("arguments[0].click();", selectResource);
final By optionsLocator = By.className("n-tree-node-content__text");
WebDriverWaitFactory.createWebDriverWait(parent().driver())
.until(ExpectedConditions.visibilityOfElementLocated(optionsLocator));
parent().driver()
.findElements(optionsLocator)
.stream()
.filter(it -> it.getText().startsWith(resourceName))
.findFirst()
.orElseThrow(() -> new RuntimeException("No such resource: " + resourceName))
.click();
parent.driver().switchTo().activeElement().sendKeys(Keys.ESCAPE);
return this;
}
Symptoms:
- The upload button sometimes isn't clicked by the automation script, causing the upload to fail.
- Even though the resource files are displayed, the script cannot click to select them.
Debugging Information:
- Checked browser console logs; no JavaScript errors are present.
- Manually performing the same actions works without any issues.
- The test environment runs normally, and both the ds system and E2E tests are operational.
Environment Information:
- DolphinScheduler (ds) system running on Java 8.
- E2E tests running on Java 11.
- Selenium WebDriver with Java for automation.
- Tests are running in a Docker container environment.
- Browser used for testing is Chrome (or Chromium).
Question:
What could be causing these intermittent issues with file uploads and resource selection in my Selenium-based E2E tests? How can I analyze and resolve these problems?
- Is it possible that the Java version differences (Java 8 vs. Java 11) between the ds system and the E2E tests are contributing to this issue?
- Could it be related to page load timing, UI rendering delays, or browser performance limitations?
- Has anyone encountered similar stability issues with Selenium WebDriver when automating file uploads and selections in web applications, and how did you solve them?
Any guidance or suggestions on how to further analyze and debug these issues would be greatly appreciated.
Tags: selenium
, java
, docker
, webdriver
, dolphinscheduler
, file-upload
, resource-selection
, java-8
, java-11
Increased waiting times using WebDriverWait to ensure elements are visible and clickable before interacting.
Used JavascriptExecutor to force-click on elements in case of overlays or hidden elements.
Verified that the file upload controls and selection boxes are fully loaded before interaction.