Skip to content

Commit

Permalink
Fix the select resource bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ailiujiarui committed Oct 30, 2024
1 parent dececfa commit 1dd1822
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static void cleanup() {
}
private static void createJar(String classFile, String entryName, String mainPackage, String jarName) {

String classFilePath = "/tmp/common/" + classFile;
String classFilePath = "/tmp/" + classFile;

String jarFilePath = "/tmp/" + jarName;

Expand Down Expand Up @@ -230,16 +230,11 @@ private static void compileJavaFlow() {
String workflowName = "compile";
String taskName = "compile";
String context =
"\n" +
"$JAVA_HOME/bin/javac -d /tmp Fat.java\n" +
"$JAVA_HOME/bin/javac -d /tmp Fat.java \n" +
"\n" +
"$JAVA_HOME/bin/javac -d /tmp Normal1.java Normal2.java \n" +
"\n" +
"$JAVA_HOME/bin/javac -d /tmp Normal2.java \n"; /*
* + "\n" + "ls \n" + "echo '%%%%%%%%%' \n" +
* "\n" + "ls /tmp \n" + "echo '%%%%%%%%%' \n" +
* "\n" + "ls /tmp/common \n";
*/
"$JAVA_HOME/bin/javac -d /tmp Normal2.java \n";
workflowDefinitionPage
.createWorkflow()
.<ShellTaskForm>addTask(WorkflowForm.TaskType.SHELL)
Expand Down Expand Up @@ -286,6 +281,8 @@ void testCreateFatWorkflow() {

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='fat.jar']")));

file.delete("Fat.java").delete("Normal1.java").delete("Normal2.java");

ProjectPage projectPage = new NavBarPage(browser)
.goToNav(ProjectPage.class);

Expand All @@ -299,8 +296,8 @@ void testCreateFatWorkflow() {
workflow1.<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
.selectRunType("FAT_JAR")
.selectMainPackage("fat.jar")
.selectResource("fat.jar")
.selectResource("fat.jar")
.selectJavaResource("fat.jar")
.selectJavaResource("fat.jar")
.name("test-1")
.selectEnv(environmentName)
.submit()
Expand Down Expand Up @@ -377,9 +374,9 @@ void testCreateNormalWorkflow() {
.<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
.selectRunType("NORMAL_JAR")
.selectMainPackage("normal1.jar")
.selectResource("normal1.jar")
.selectResource("normal1.jar")
.selectResource("normal2.jar")
.selectJavaResource("normal1.jar")
.selectJavaResource("normal1.jar")
.selectJavaResource("normal2.jar")
.name("test-2")
.selectEnv(environmentName)
.submit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,24 @@ public JavaTaskForm(WorkflowForm parent) {
}

public JavaTaskForm selectJavaResource(String resourceName) {
((JavascriptExecutor) driver).executeScript("arguments[0].click();", selectResource);

final By optionsLocator = By.className("n-tree-node-content__text");

WebDriverWait wait = WebDriverWaitFactory.createWebDriverWait(driver());
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);
}
List<WebElement> elements = driver.findElements(optionsLocator);

WebElement targetElement = elements.stream()
.filter(it -> it.getText().trim().equals(resourceName))
.findFirst()
.orElseThrow(() -> new RuntimeException("No such package: " + resourceName));

targetElement.click();

driver.switchTo().activeElement().sendKeys(Keys.ESCAPE);

return this;
}

Expand Down

0 comments on commit 1dd1822

Please sign in to comment.