SbloodyS commented on code in PR #16542:
URL: 
https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1809736309


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -97,6 +100,11 @@ public static void setup() {
         userPage.update(user, user, email, phone, tenant)
                 .goToNav(ProjectPage.class)
                 .create(project);
+
+        ProjectPage projectPage = new ProjectPage(browser);
+        Awaitility.await().untilAsserted(() -> 
assertThat(projectPage.projectList())
+                .as("项目列表应包含新创建的项目")

Review Comment:
   Please using english.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+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.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run 
Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main 
Package']]/following-sibling::div//div[contains(@class, 
'n-base-selection-label')]")
+    private WebElement selectMainPackage;
+
+    @FindBy(xpath = "//div[@class='n-form-item-blank']//div[contains(@class, 
'n-base-selection--multiple')]//div[contains(@class, 'n-base-selection-tags') 
and @tabindex='0']")

Review Comment:
   Same here.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+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.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run 
Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main 
Package']]/following-sibling::div//div[contains(@class, 
'n-base-selection-label')]")
+    private WebElement selectMainPackage;
+
+    @FindBy(xpath = "//div[@class='n-form-item-blank']//div[contains(@class, 
'n-base-selection--multiple')]//div[contains(@class, 'n-base-selection-tags') 
and @tabindex='0']")
+    private WebElement selectResource;
+
     public JavaTaskForm(WorkflowForm parent) {
         super(parent);
 
-        this.codeEditor = new CodeEditor(parent.driver());
-
         this.driver = parent.driver();
+
+        PageFactory.initElements(driver, this);
     }
 
-    public JavaTaskForm script(String script) {
-        codeEditor.content(script);
+    public TaskNodeForm selectResource(String resourceName) {
+        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));
+        wait.until(ExpectedConditions.elementToBeClickable(selectResource));
+        ((JavascriptExecutor) 
driver).executeScript("arguments[0].scrollIntoView(true); 
arguments[0].click();",
+                selectResource);
+        By optionsLocator = By.className("n-tree-node-content__text");
+        
wait.until(ExpectedConditions.visibilityOfElementLocated(optionsLocator));
+
+        List<WebElement> options = driver.findElements(optionsLocator);
+        boolean found = false;
+        for (WebElement option : options) {
+            if (option.getText().trim().startsWith(resourceName)) {
+                ((JavascriptExecutor) 
driver).executeScript("arguments[0].scrollIntoView(true); 
arguments[0].click();",
+                        option);
+                found = true;
+                break;
+            }
+        }
+
+        if (!found) {
+            throw new RuntimeException("Cannot Found: " + resourceName);
+        }
+
+        driver.switchTo().activeElement().sendKeys(Keys.ESCAPE);
         return this;
     }
+
+    public JavaTaskForm selectRunType(String runType) {
+        WebDriverWait wait = new WebDriverWait(driver, 
Duration.ofSeconds(60)); // 增加等待时间

Review Comment:
   ```suggestion
           WebDriverWait wait = new WebDriverWait(driver, 
Duration.ofSeconds(60));
   ```



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -163,17 +183,112 @@ void testRunWorkflow() {
                 .run(workflow)
                 .submit();
 
-        Awaitility.await().untilAsserted(() -> {
-            browser.navigate().refresh();
+        Awaitility.await()
+                .atMost(Duration.ofMinutes(5))
+                .untilAsserted(() -> {
+                    browser.navigate().refresh();
+
+                    final WorkflowInstanceTab.Row row = projectPage
+                            .goToTab(WorkflowInstanceTab.class)
+                            .instances()
+                            .iterator()
+                            .next();
 
-            final WorkflowInstanceTab.Row row = projectPage
-                    .goToTab(WorkflowInstanceTab.class)
-                    .instances()
-                    .iterator()
-                    .next();
+                    assertThat(row.isSuccess()).isTrue();
+                    assertThat(row.executionTime()).isEqualTo(1);
+                });
 
-            assertThat(row.isSuccess()).isTrue();
-            assertThat(row.executionTime()).isEqualTo(1);
-        });
     }
+
+    @Test
+    @Order(60)
+    void testCreateNormalWorkflow() {
+        FileManagePage file = new NavBarPage(browser)
+                .goToNav(ResourcePage.class)
+                .goToTab(FileManagePage.class)
+                .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("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);
+    }
+
+    @Test
+    @Order(90)
+    void testRunNormalWorkflow() {
+        final ProjectDetailPage projectPage =
+                new ProjectPage(browser)
+                        .goToNav(ProjectPage.class)
+                        .goTo(project);
+
+        projectPage
+                .goToTab(WorkflowInstanceTab.class)
+                .deleteAll();
+        projectPage
+                .goToTab(WorkflowDefinitionTab.class)
+                .run(workflow2)
+                .submit();
+
+        Awaitility.await()
+                .atMost(Duration.ofMinutes(5))
+                .untilAsserted(() -> {
+                    browser.navigate().refresh();
+
+                    final WorkflowInstanceTab.Row row = projectPage
+                            .goToTab(WorkflowInstanceTab.class)
+                            .instances()
+                            .iterator()
+                            .next();
+
+                    assertThat(row.isSuccess()).isTrue();
+                    assertThat(row.executionTime()).isEqualTo(1);
+                });
+        /*
+         * Awaitility.await() .atMost(Duration.ofMinutes(5)) .untilAsserted(() 
-> { browser.navigate().refresh();
+         * 
+         * final WorkflowInstanceTab workflowInstanceTab = 
projectPage.goToTab(WorkflowInstanceTab.class);
+         * 
+         * List<WorkflowInstanceTab.Row> instances = 
workflowInstanceTab.instances();
+         * 
+         * if (instances.isEmpty()) { throw new RuntimeException("No workflow 
instances found"); }
+         * 
+         * WorkflowInstanceTab.Row row = instances.get(0);
+         * 
+         * assertThat(row.isSuccess()).isTrue(); 
assertThat(row.executionTime()).isEqualTo(1); });
+         */

Review Comment:
   Avoid unnessnary comment. Remove this.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,43 +132,48 @@ public void handle(TaskCallBack taskCallBack) throws 
TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
+        builder.append(getJavaCommandPath())
                 .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(mainJarAbsolutePathInLocal).append(" ")
                 .append(javaParameters.getMainArgs().trim()).append(" ")
                 .append(javaParameters.getJvmArgs().trim());
         return builder.toString();
     }
 
     /**
-     * Construct a shell command for the java -jar Run mode
+     * Construct a shell command for the java -cp run mode
      *
      * @return String
      **/
-    protected String buildJarCommand() {
+    protected String buildNormalJarCommand() {
         ResourceContext resourceContext = taskRequest.getResourceContext();
-        String mainJarAbsolutePathInLocal = resourceContext
-                .getResourceItem(javaParameters.getMainJar().getResourceName())
+        String mainJarAbsolutePathInLocal = resourceContext.getResourceItem(
+                javaParameters.getMainJar()
+                        .getResourceName())
                 .getResourceAbsolutePathInLocal();
+        String mainJarName = null;
+        try {
+            mainJarName = 
MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal);
+        } catch (Exception e) {
+            e.printStackTrace();

Review Comment:
   ```suggestion
               logger.error("get mainJarName failed:", e);
   ```



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+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.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run 
Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main 
Package']]/following-sibling::div//div[contains(@class, 
'n-base-selection-label')]")
+    private WebElement selectMainPackage;
+
+    @FindBy(xpath = "//div[@class='n-form-item-blank']//div[contains(@class, 
'n-base-selection--multiple')]//div[contains(@class, 'n-base-selection-tags') 
and @tabindex='0']")
+    private WebElement selectResource;
+
     public JavaTaskForm(WorkflowForm parent) {
         super(parent);
 
-        this.codeEditor = new CodeEditor(parent.driver());
-
         this.driver = parent.driver();
+
+        PageFactory.initElements(driver, this);
     }
 
-    public JavaTaskForm script(String script) {
-        codeEditor.content(script);
+    public TaskNodeForm selectResource(String resourceName) {
+        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));

Review Comment:
   Please using `WebDriverWaitFactory.createWebDriverWait(page.driver())` 
instead.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/fat.jar:
##########


Review Comment:
   You should create a folder like 
`dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/java-task`
 and put all these jars into it. And mount it into ds's docker image. Otherwise 
the test would fail.
   
   In addition, You should add some docs of the content of these three jars 
content for others to understand.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+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.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run 
Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main 
Package']]/following-sibling::div//div[contains(@class, 
'n-base-selection-label')]")

Review Comment:
   Same here.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,43 +132,48 @@ public void handle(TaskCallBack taskCallBack) throws 
TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
+        builder.append(getJavaCommandPath())
                 .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(mainJarAbsolutePathInLocal).append(" ")

Review Comment:
   Using `Constants.SPACE` instead of this.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+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.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run 
Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")

Review Comment:
   This xpath is too extensive and unstable, please add class name to the 
button before using it.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,43 +132,48 @@ public void handle(TaskCallBack taskCallBack) throws 
TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
+        builder.append(getJavaCommandPath())
                 .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(mainJarAbsolutePathInLocal).append(" ")
                 .append(javaParameters.getMainArgs().trim()).append(" ")
                 .append(javaParameters.getJvmArgs().trim());
         return builder.toString();
     }
 
     /**
-     * Construct a shell command for the java -jar Run mode
+     * Construct a shell command for the java -cp run mode
      *
      * @return String
      **/
-    protected String buildJarCommand() {
+    protected String buildNormalJarCommand() {
         ResourceContext resourceContext = taskRequest.getResourceContext();
-        String mainJarAbsolutePathInLocal = resourceContext
-                .getResourceItem(javaParameters.getMainJar().getResourceName())
+        String mainJarAbsolutePathInLocal = resourceContext.getResourceItem(
+                javaParameters.getMainJar()
+                        .getResourceName())
                 .getResourceAbsolutePathInLocal();
+        String mainJarName = null;
+        try {
+            mainJarName = 
MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         StringBuilder builder = new StringBuilder();
         builder.append(getJavaCommandPath())
                 .append("java").append(" ")
                 .append(buildResourcePath()).append(" ")
-                .append("-jar").append(" ")
-                .append(mainJarAbsolutePathInLocal).append(" ")
+                .append(mainJarName).append(" ")

Review Comment:
   Same here.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+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.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run 
Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main 
Package']]/following-sibling::div//div[contains(@class, 
'n-base-selection-label')]")
+    private WebElement selectMainPackage;
+
+    @FindBy(xpath = "//div[@class='n-form-item-blank']//div[contains(@class, 
'n-base-selection--multiple')]//div[contains(@class, 'n-base-selection-tags') 
and @tabindex='0']")
+    private WebElement selectResource;
+
     public JavaTaskForm(WorkflowForm parent) {
         super(parent);
 
-        this.codeEditor = new CodeEditor(parent.driver());
-
         this.driver = parent.driver();
+
+        PageFactory.initElements(driver, this);
     }
 
-    public JavaTaskForm script(String script) {
-        codeEditor.content(script);
+    public TaskNodeForm selectResource(String resourceName) {
+        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));
+        wait.until(ExpectedConditions.elementToBeClickable(selectResource));
+        ((JavascriptExecutor) 
driver).executeScript("arguments[0].scrollIntoView(true); 
arguments[0].click();",
+                selectResource);
+        By optionsLocator = By.className("n-tree-node-content__text");
+        
wait.until(ExpectedConditions.visibilityOfElementLocated(optionsLocator));
+
+        List<WebElement> options = driver.findElements(optionsLocator);
+        boolean found = false;
+        for (WebElement option : options) {
+            if (option.getText().trim().startsWith(resourceName)) {
+                ((JavascriptExecutor) 
driver).executeScript("arguments[0].scrollIntoView(true); 
arguments[0].click();",
+                        option);
+                found = true;
+                break;
+            }
+        }
+
+        if (!found) {
+            throw new RuntimeException("Cannot Found: " + resourceName);
+        }
+
+        driver.switchTo().activeElement().sendKeys(Keys.ESCAPE);
         return this;
     }
+
+    public JavaTaskForm selectRunType(String runType) {
+        WebDriverWait wait = new WebDriverWait(driver, 
Duration.ofSeconds(60)); // 增加等待时间

Review Comment:
   Same here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to