|
|
|
@ -26,12 +26,16 @@ import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
|
|
|
|
|
import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; |
|
|
|
|
|
|
|
|
|
import org.openqa.selenium.By; |
|
|
|
|
import org.openqa.selenium.JavascriptExecutor; |
|
|
|
|
import org.openqa.selenium.Keys; |
|
|
|
|
import org.openqa.selenium.WebElement; |
|
|
|
|
import org.openqa.selenium.remote.LocalFileDetector; |
|
|
|
|
import org.openqa.selenium.remote.RemoteWebDriver; |
|
|
|
|
import org.openqa.selenium.support.FindBy; |
|
|
|
|
import org.openqa.selenium.support.FindBys; |
|
|
|
|
import org.openqa.selenium.support.PageFactory; |
|
|
|
|
import org.openqa.selenium.support.ui.ExpectedConditions; |
|
|
|
|
import org.openqa.selenium.support.ui.WebDriverWait; |
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.util.List; |
|
|
|
@ -39,45 +43,46 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Getter |
|
|
|
|
public class FileManagePage extends NavBarPage implements ResourcePage.Tab { |
|
|
|
|
@FindBy(id = "btnCreateDirectory") |
|
|
|
|
@FindBy(className = "btn-create-directory") |
|
|
|
|
private WebElement buttonCreateDirectory; |
|
|
|
|
|
|
|
|
|
@FindBy(id = "btnCreateFile") |
|
|
|
|
@FindBy(className = "btn-create-file") |
|
|
|
|
private WebElement buttonCreateFile; |
|
|
|
|
|
|
|
|
|
@FindBy(id = "btnUploadFile") |
|
|
|
|
@FindBy(className = "btn-upload-file") |
|
|
|
|
private WebElement buttonUploadFile; |
|
|
|
|
|
|
|
|
|
private final CreateDirectoryBox createDirectoryBox; |
|
|
|
|
|
|
|
|
|
private final RenameDirectoryBox renameDirectoryBox; |
|
|
|
|
private final RenameBox renameBox; |
|
|
|
|
|
|
|
|
|
private final CreateFileBox createFileBox; |
|
|
|
|
|
|
|
|
|
private final UploadFileBox uploadFileBox; |
|
|
|
|
|
|
|
|
|
private final EditFileBox editFileBox; |
|
|
|
|
|
|
|
|
|
@FindBy(className = "items") |
|
|
|
|
private List<WebElement> fileList; |
|
|
|
|
|
|
|
|
|
@FindBy(id = "delete") |
|
|
|
|
private WebElement buttonDelete; |
|
|
|
|
|
|
|
|
|
@FindBys({ |
|
|
|
|
@FindBy(className = "el-popconfirm"), |
|
|
|
|
@FindBy(className = "el-button--primary"), |
|
|
|
|
@FindBy(className = "n-popconfirm__action"), |
|
|
|
|
@FindBy(className = "n-button--primary-type"), |
|
|
|
|
}) |
|
|
|
|
private List<WebElement> buttonConfirm; |
|
|
|
|
private WebElement buttonConfirm; |
|
|
|
|
|
|
|
|
|
public FileManagePage(RemoteWebDriver driver) { |
|
|
|
|
super(driver); |
|
|
|
|
|
|
|
|
|
createDirectoryBox = new CreateDirectoryBox(); |
|
|
|
|
|
|
|
|
|
renameDirectoryBox = new RenameDirectoryBox(); |
|
|
|
|
renameBox = new RenameBox(); |
|
|
|
|
|
|
|
|
|
createFileBox = new CreateFileBox(); |
|
|
|
|
|
|
|
|
|
uploadFileBox = new UploadFileBox(); |
|
|
|
|
|
|
|
|
|
editFileBox = new EditFileBox(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public FileManagePage createDirectory(String name, String description) { |
|
|
|
@ -104,15 +109,16 @@ public class FileManagePage extends NavBarPage implements ResourcePage.Tab {
|
|
|
|
|
fileList() |
|
|
|
|
.stream() |
|
|
|
|
.filter(it -> it.getText().contains(currentName)) |
|
|
|
|
.flatMap(it -> it.findElements(By.id("btnRename")).stream()) |
|
|
|
|
.flatMap(it -> it.findElements(By.className("btn-rename")).stream()) |
|
|
|
|
.filter(WebElement::isDisplayed) |
|
|
|
|
.findFirst() |
|
|
|
|
.orElseThrow(() -> new RuntimeException("No rename button in file manage list")) |
|
|
|
|
.click(); |
|
|
|
|
|
|
|
|
|
renameDirectoryBox().inputName().clear(); |
|
|
|
|
renameDirectoryBox().inputName().sendKeys(AfterName); |
|
|
|
|
renameDirectoryBox().buttonSubmit().click(); |
|
|
|
|
renameBox().inputName().sendKeys(Keys.CONTROL + "a"); |
|
|
|
|
renameBox().inputName().sendKeys(Keys.BACK_SPACE); |
|
|
|
|
renameBox().inputName().sendKeys(AfterName); |
|
|
|
|
renameBox().buttonSubmit().click(); |
|
|
|
|
|
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
@ -139,18 +145,13 @@ public class FileManagePage extends NavBarPage implements ResourcePage.Tab {
|
|
|
|
|
fileList() |
|
|
|
|
.stream() |
|
|
|
|
.filter(it -> it.getText().contains(name)) |
|
|
|
|
.flatMap(it -> it.findElements(By.id("delete")).stream()) |
|
|
|
|
.flatMap(it -> it.findElements(By.className("btn-delete")).stream()) |
|
|
|
|
.filter(WebElement::isDisplayed) |
|
|
|
|
.findFirst() |
|
|
|
|
.orElseThrow(() -> new RuntimeException("No delete button in file manage list")) |
|
|
|
|
.click(); |
|
|
|
|
|
|
|
|
|
buttonConfirm() |
|
|
|
|
.stream() |
|
|
|
|
.filter(WebElement::isDisplayed) |
|
|
|
|
.findFirst() |
|
|
|
|
.orElseThrow(() -> new RuntimeException("No confirm button when deleting")) |
|
|
|
|
.click(); |
|
|
|
|
((JavascriptExecutor) driver).executeScript("arguments[0].click();", buttonConfirm()); |
|
|
|
|
|
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
@ -169,14 +170,16 @@ public class FileManagePage extends NavBarPage implements ResourcePage.Tab {
|
|
|
|
|
fileList() |
|
|
|
|
.stream() |
|
|
|
|
.filter(it -> it.getText().contains(fileName)) |
|
|
|
|
.flatMap(it -> it.findElements(By.id("btnEdit")).stream()) |
|
|
|
|
.flatMap(it -> it.findElements(By.className("btn-edit")).stream()) |
|
|
|
|
.filter(WebElement::isDisplayed) |
|
|
|
|
.findFirst() |
|
|
|
|
.orElseThrow(() -> new RuntimeException("No edit button in file manage list")) |
|
|
|
|
.click(); |
|
|
|
|
|
|
|
|
|
createFileBox().codeEditor().content(scripts); |
|
|
|
|
createFileBox().buttonSubmit().click(); |
|
|
|
|
new WebDriverWait(driver, 5).until(ExpectedConditions.urlContains("/edit")); |
|
|
|
|
|
|
|
|
|
editFileBox().codeEditor().content(scripts); |
|
|
|
|
editFileBox().buttonSubmit().click(); |
|
|
|
|
|
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
@ -196,7 +199,7 @@ public class FileManagePage extends NavBarPage implements ResourcePage.Tab {
|
|
|
|
|
fileList() |
|
|
|
|
.stream() |
|
|
|
|
.filter(it -> it.getText().contains(fileName)) |
|
|
|
|
.flatMap(it -> it.findElements(By.id("btnDownload")).stream()) |
|
|
|
|
.flatMap(it -> it.findElements(By.className("btn-download")).stream()) |
|
|
|
|
.filter(WebElement::isDisplayed) |
|
|
|
|
.findFirst() |
|
|
|
|
.orElseThrow(() -> new RuntimeException("No download button in file manage list")) |
|
|
|
@ -211,35 +214,47 @@ public class FileManagePage extends NavBarPage implements ResourcePage.Tab {
|
|
|
|
|
PageFactory.initElements(driver, this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@FindBy(id = "inputDirectoryName") |
|
|
|
|
@FindBys({ |
|
|
|
|
@FindBy(className = "input-directory-name"), |
|
|
|
|
@FindBy(tagName = "input"), |
|
|
|
|
}) |
|
|
|
|
private WebElement inputDirectoryName; |
|
|
|
|
|
|
|
|
|
@FindBy(id = "inputDescription") |
|
|
|
|
@FindBys({ |
|
|
|
|
@FindBy(className = "input-description"), |
|
|
|
|
@FindBy(tagName = "textarea"), |
|
|
|
|
}) |
|
|
|
|
private WebElement inputDescription; |
|
|
|
|
|
|
|
|
|
@FindBy(id = "btnSubmit") |
|
|
|
|
@FindBy(className = "btn-submit") |
|
|
|
|
private WebElement buttonSubmit; |
|
|
|
|
|
|
|
|
|
@FindBy(id = "btnCancel") |
|
|
|
|
@FindBy(className = "btn-cancel") |
|
|
|
|
private WebElement buttonCancel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Getter |
|
|
|
|
public class RenameDirectoryBox { |
|
|
|
|
RenameDirectoryBox() { |
|
|
|
|
public class RenameBox { |
|
|
|
|
RenameBox() { |
|
|
|
|
PageFactory.initElements(driver, this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@FindBy(id = "inputName") |
|
|
|
|
@FindBys({ |
|
|
|
|
@FindBy(className = "input-name"), |
|
|
|
|
@FindBy(tagName = "input"), |
|
|
|
|
}) |
|
|
|
|
private WebElement inputName; |
|
|
|
|
|
|
|
|
|
@FindBy(id = "inputDescription") |
|
|
|
|
@FindBys({ |
|
|
|
|
@FindBy(className = "input-description"), |
|
|
|
|
@FindBy(tagName = "textarea"), |
|
|
|
|
}) |
|
|
|
|
private WebElement inputDescription; |
|
|
|
|
|
|
|
|
|
@FindBy(id = "btnSubmit") |
|
|
|
|
@FindBy(className = "btn-submit") |
|
|
|
|
private WebElement buttonSubmit; |
|
|
|
|
|
|
|
|
|
@FindBy(id = "btnCancel") |
|
|
|
|
@FindBy(className = "btn-cancel") |
|
|
|
|
private WebElement buttonCancel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -249,15 +264,33 @@ public class FileManagePage extends NavBarPage implements ResourcePage.Tab {
|
|
|
|
|
PageFactory.initElements(driver, this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@FindBy(id = "inputFileName") |
|
|
|
|
@FindBys({ |
|
|
|
|
@FindBy(className = "input-file-name"), |
|
|
|
|
@FindBy(tagName = "input"), |
|
|
|
|
}) |
|
|
|
|
private WebElement inputFileName; |
|
|
|
|
|
|
|
|
|
private final CodeEditor codeEditor = new CodeEditor(driver); |
|
|
|
|
|
|
|
|
|
@FindBy(id = "btnSubmit") |
|
|
|
|
@FindBy(className = "btn-submit") |
|
|
|
|
private WebElement buttonSubmit; |
|
|
|
|
|
|
|
|
|
@FindBy(className = "btn-cancel") |
|
|
|
|
private WebElement buttonCancel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Getter |
|
|
|
|
public class EditFileBox { |
|
|
|
|
EditFileBox() { |
|
|
|
|
PageFactory.initElements(driver, this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CodeEditor codeEditor = new CodeEditor(driver); |
|
|
|
|
|
|
|
|
|
@FindBy(className = "btn-submit") |
|
|
|
|
private WebElement buttonSubmit; |
|
|
|
|
|
|
|
|
|
@FindBy(id = "btnCancel") |
|
|
|
|
@FindBy(className = "btn-cancel") |
|
|
|
|
private WebElement buttonCancel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -267,13 +300,16 @@ public class FileManagePage extends NavBarPage implements ResourcePage.Tab {
|
|
|
|
|
PageFactory.initElements(driver, this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@FindBy(id = "btnUpload") |
|
|
|
|
@FindBys({ |
|
|
|
|
@FindBy(className = "btn-upload"), |
|
|
|
|
@FindBy(tagName = "input"), |
|
|
|
|
}) |
|
|
|
|
private WebElement buttonUpload; |
|
|
|
|
|
|
|
|
|
@FindBy(id = "btnSubmit") |
|
|
|
|
@FindBy(className = "btn-submit") |
|
|
|
|
private WebElement buttonSubmit; |
|
|
|
|
|
|
|
|
|
@FindBy(id = "btnCancel") |
|
|
|
|
@FindBy(className = "btn-cancel") |
|
|
|
|
private WebElement buttonCancel; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|