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


##########
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:
   The code has been modified



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