From f407adcb71be734cede10fbcecc6d7bbe1f2e7fd Mon Sep 17 00:00:00 2001 From: xingchun-chen <55787491+xingchun-chen@users.noreply.github.com> Date: Thu, 27 Feb 2020 11:43:09 +0800 Subject: [PATCH] =?UTF-8?q?Add=20e2e=20to=20create=20workflow=20case=20?= =?UTF-8?q?=C2=A0=20(#2027)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add e2e * add ui-test * add e2e license and notice * add e2e license * add license * add ui-test * add ui-test * add ui-test * e2e delete dolphinscheduler parent project dependency * add ui-test * dolphinscheduler_dist delete e2e license/notice * dolphinscheduler_dist delete e2e license/notice * dolphinscheduler_dist delete e2e license/notice * dolphinscheduler_dist delete e2e license/notice * pom.xml delete e2e dependency * add e2e create workflow * Merge remote-tracking branch 'upstream/dev' into dev # Conflicts: # e2e/src/test/java/org/apache/dolphinscheduler/base/BaseDriver.java * Merge remote-tracking branch 'upstream/dev' into dev # Conflicts: # e2e/src/test/java/org/apache/dolphinscheduler/base/BaseDriver.java * Merge remote-tracking branch 'upstream/dev' into dev # Conflicts: # e2e/src/test/java/org/apache/dolphinscheduler/base/BaseDriver.java * Merge remote-tracking branch 'upstream/dev' into dev # Conflicts: # e2e/src/test/java/org/apache/dolphinscheduler/base/BaseDriver.java * modify workflow case Co-authored-by: chenxingchun <50446296+chenxingchun@users.noreply.github.com> --- .../dolphinscheduler/base/BaseDriver.java | 6 ++ .../common/BrowserCommon.java | 45 +++++++++++---- .../data/project/CreatWorkflowData.java | 12 +++- .../project/CreateWorkflowLocator.java | 34 +++++++++--- .../page/project/CreateProjectPage.java | 4 +- .../page/project/CreateWorkflowPage.java | 55 ++++++++++++++----- .../testcase/project/CreateProjectTest.java | 2 +- .../testcase/project/CreateWorkflowTest.java | 11 ++-- 8 files changed, 128 insertions(+), 41 deletions(-) diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/base/BaseDriver.java b/e2e/src/test/java/org/apache/dolphinscheduler/base/BaseDriver.java index 86a77ffcfd..7d3ab9b837 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/base/BaseDriver.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/base/BaseDriver.java @@ -27,6 +27,7 @@ import java.io.IOException; import java.util.concurrent.TimeUnit; import org.openqa.selenium.PageLoadStrategy; + /** * base driver class */ @@ -97,8 +98,13 @@ public class BaseDriver { /* driver setting wait time */ // implicitly wait time driver.manage().timeouts().implicitlyWait(implicitlyWait, TimeUnit.SECONDS); + + // page load timeout + driver.manage().timeouts().pageLoadTimeout(pageLoadTimeout, TimeUnit.SECONDS); + // page load timeout driver.manage().timeouts().pageLoadTimeout(pageLoadTimeout, TimeUnit.SECONDS); + // script timeout driver.manage().timeouts().setScriptTimeout(setScriptTimeout, TimeUnit.SECONDS); diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/common/BrowserCommon.java b/e2e/src/test/java/org/apache/dolphinscheduler/common/BrowserCommon.java index fb16162d55..072ccb652e 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/common/BrowserCommon.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/common/BrowserCommon.java @@ -99,8 +99,6 @@ public class BrowserCommon { // show wait timeout long timeout = Long.valueOf(PropertiesReader.getKey("driver.timeouts.webDriverWait")); wait = new WebDriverWait(driver, timeout); -// this.redisUtil = redisUtil; -// this.jedis = redisUtil.getJedis(); } @@ -158,22 +156,34 @@ public class BrowserCommon { * * @param locator By */ - public void clearInput(By locator) { + public WebElement clearInput(By locator) { WebElement clearElement = locateElement(locator); clearElement.click(); - clearElement.clear(); clearElement.sendKeys(Keys.chord(Keys.CONTROL, "a")); - clearElement.sendKeys(Keys.DELETE); + clearElement.sendKeys(Keys.BACK_SPACE); + return clearElement; } + /** + * input codeMirror + * + * @param codeMirrorLocator By codeMirror + * @param codeMirrorLineLocator By codeMirrorLine + + */ + public void inputCodeMirror(By codeMirrorLocator,By codeMirrorLineLocator,String content) { + WebElement codeMirrorElement = locateElement(codeMirrorLocator); + WebElement codeMirrorLineElement = locateElement(codeMirrorLineLocator); + codeMirrorElement.click(); + codeMirrorLineElement.sendKeys(content); + } /** * move to element - * * @param locator BY * @return actions */ - public Actions moveToElement(By locator) { + public Actions moveToElement(By locator){ return actions.moveToElement(locateElement(locator)); } @@ -182,13 +192,17 @@ public class BrowserCommon { * * @param source_locator BY * @param target_locator BY - * @param X X-axis - * @param Y Y-axis */ - public void dragAndDropBy(By source_locator, By target_locator, int X, int Y) { - WebElement sourcetElement = locateElement(source_locator); + public void dragAndDrop(By source_locator, By target_locator){ + WebElement sourceElement = locateElement(source_locator); + WebElement targetElement = locateElement(target_locator); + actions.dragAndDrop(sourceElement, targetElement).perform(); + actions.release(); + } + + public void moveToDragElement(By target_locator, int X, int Y){ WebElement targetElement = locateElement(target_locator); - actions.dragAndDrop(sourcetElement, targetElement).moveToElement(targetElement, X, Y).perform(); + actions.dragAndDropBy(targetElement, X, Y).perform(); actions.release(); } @@ -300,6 +314,13 @@ public class BrowserCommon { executeScript("window.scrollTo(0, document.body.scrollHeight)"); } + public void scrollToElementBottom() { + + WebElement webElement = driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div/div[2]/div/div[7]/div[3]")); + ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", webElement); + } + + /** * Page swipe makes the top of the element align with the top of the page * diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/data/project/CreatWorkflowData.java b/e2e/src/test/java/org/apache/dolphinscheduler/data/project/CreatWorkflowData.java index 1e45d47a92..765a54f406 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/data/project/CreatWorkflowData.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/data/project/CreatWorkflowData.java @@ -29,8 +29,18 @@ public class CreatWorkflowData { //input shell script public static final String SHELL_SCRIPT = "echo 1111111"; - public static final String WORKFLOW_TITLE = "创建流程定义 - DolphinScheduler"; + //input custom parameters + public static final String INPUT_CUSTOM_PARAMETERS = "selenium_parameter"; + + //input custom parameters value + public static final String INPUT_CUSTOM_PARAMETERS_VALUE = "selenium_parameter_123"; + //input add custom parameters + public static final String INPUT_ADD_CUSTOM_PARAMETERS = "selenium_parameter_delete"; + //input add custom parameters value + public static final String INPUT_ADD_CUSTOM_PARAMETERS_VALUE = "selenium_parameter_delete_456"; + //create workflow title + public static final String WORKFLOW_TITLE = "创建流程定义 - DolphinScheduler"; } diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/locator/project/CreateWorkflowLocator.java b/e2e/src/test/java/org/apache/dolphinscheduler/locator/project/CreateWorkflowLocator.java index 3bea648d57..f063d6ef61 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/locator/project/CreateWorkflowLocator.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/locator/project/CreateWorkflowLocator.java @@ -20,9 +20,6 @@ package org.apache.dolphinscheduler.locator.project; import org.openqa.selenium.By; public class CreateWorkflowLocator { - // click project manage - public static final By CLICK_PROJECT_MANAGE = By.xpath("//div[2]/div/a/span"); - // click project name public static final By CLICK_PROJECT_NAME = By.xpath("//span/a"); @@ -33,16 +30,13 @@ public class CreateWorkflowLocator { public static final By CLICK_CREATE_WORKFLOW_BUTTON = By.xpath("//button/span"); //mouse down at shell - public static final By MOUSE_DOWN_AT_SHELL = By.xpath("//*[@id='SHELL']/div/div"); + public static final By MOUSE_DOWN_AT_SHELL = By.xpath("//div[@id='SHELL']/div/div"); //mouse down at spark public static final By MOUSE_DOWN_AT_SPARK = By.xpath("//div[5]/div/div"); //mouse move at DAG - public static final By MOUSE_MOVE_SHELL_AT_DAG = By.xpath("//div[2]/div/div[2]/div[2]/div/div"); - -// //click shell task -// public static final By CLICK_SHELL_TASK = By.xpath("//div[2]/div/div[2]/div[2]/div/div"); + public static final By MOUSE_MOVE_SHELL_AT_DAG = By.xpath("//div[@id='canvas']"); //input shell task _name public static final By INPUT_SHELL_TASK_NAME = By.xpath("//input"); @@ -89,9 +83,33 @@ public class CreateWorkflowLocator { //input timeout public static final By SELECT_TIMEOUT = By.xpath("//div[3]/div[2]/label/div/input"); + //click codeMirror + public static final By CLICK_CODE_MIRROR = By.xpath("//div[5]/div/pre"); + //input script public static final By INPUT_SCRIPT = By.xpath("//div[2]/div/div/div/div/div/textarea"); + //click custom parameters + public static final By CLICK_CUSTOM_PARAMETERS = By.xpath("//span/a/em"); + + //input custom parameters + public static final By INPUT_CUSTOM_PARAMETERS = By.xpath("//div[2]/div/div/div/div/div/input"); + + //input custom parameters value + public static final By INPUT_CUSTOM_PARAMETERS_VALUE = By.xpath("//div[2]/input"); + + //click add custom parameters + public static final By CLICK_ADD_CUSTOM_PARAMETERS = By.xpath("//span[2]/a/em"); + + //input add custom parameters + public static final By INPUT_ADD_CUSTOM_PARAMETERS = By.xpath("//div[2]/div/div/div/div[2]/div/input"); + + //input add custom parameters value + public static final By INPUT_ADD_CUSTOM_PARAMETERS_VALUE = By.xpath("//div[2]/div[2]/input"); + //delete custom parameters + public static final By CLICK_DELETE_CUSTOM_PARAMETERS = By.xpath("//div[2]/span/a/em"); + //click submit button + public static final By CLICK_SUBMIT_BUTTON = By.xpath("//button[2]/span"); } diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/page/project/CreateProjectPage.java b/e2e/src/test/java/org/apache/dolphinscheduler/page/project/CreateProjectPage.java index 796171542b..8dd1010a82 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/page/project/CreateProjectPage.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/page/project/CreateProjectPage.java @@ -29,9 +29,10 @@ public class CreateProjectPage extends PageCommon { /** * jump page */ - public void jumpPage() throws InterruptedException { + public void jumpProjectManagePage() throws InterruptedException { Thread.sleep(TestConstant.ONE_THOUSANG); clickElement(CreateProjectLocator.PROJECT_MANAGE); + Thread.sleep(TestConstant.ONE_THOUSANG); } /** @@ -40,7 +41,6 @@ public class CreateProjectPage extends PageCommon { * @return Whether to enter the specified page after creat tenant */ public boolean createProject() throws InterruptedException { - Thread.sleep(TestConstant.ONE_THOUSANG); //click create project clickElement(CreateProjectLocator.CREATE_PROJECT_BUTTON); Thread.sleep(TestConstant.ONE_THOUSANG); diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/page/project/CreateWorkflowPage.java b/e2e/src/test/java/org/apache/dolphinscheduler/page/project/CreateWorkflowPage.java index 827198bd86..aeec83cd19 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/page/project/CreateWorkflowPage.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/page/project/CreateWorkflowPage.java @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.page.project; import org.apache.dolphinscheduler.common.PageCommon; import org.apache.dolphinscheduler.constant.TestConstant; import org.apache.dolphinscheduler.data.project.CreatWorkflowData; -import org.apache.dolphinscheduler.locator.project.CreateProjectLocator; import org.apache.dolphinscheduler.locator.project.CreateWorkflowLocator; import org.openqa.selenium.WebDriver; @@ -30,24 +29,23 @@ public class CreateWorkflowPage extends PageCommon { /** * jump page */ - public boolean CreateWorkflow() throws InterruptedException { - Thread.sleep(TestConstant.ONE_THOUSANG); - // click project manage - clickElement(CreateProjectLocator.PROJECT_MANAGE); - Thread.sleep(TestConstant.ONE_THOUSANG); + public boolean createWorkflow() throws InterruptedException { // click project name clickElement(CreateWorkflowLocator.CLICK_PROJECT_NAME); Thread.sleep(TestConstant.ONE_THOUSANG); + // click workflow define clickElement(CreateWorkflowLocator.CLICK_WORKFLOW_DEFINE); + Thread.sleep(TestConstant.ONE_THOUSANG); // click create workflow button clickElement(CreateWorkflowLocator.CLICK_CREATE_WORKFLOW_BUTTON); + Thread.sleep(TestConstant.ONE_THOUSANG); //drag shell_task - dragAndDropBy(CreateWorkflowLocator.MOUSE_DOWN_AT_SHELL,CreateWorkflowLocator.MOUSE_MOVE_SHELL_AT_DAG, 3 ,6); + dragAndDrop(CreateWorkflowLocator.MOUSE_DOWN_AT_SHELL,CreateWorkflowLocator.MOUSE_MOVE_SHELL_AT_DAG); //input shell task _name sendInput(CreateWorkflowLocator.INPUT_SHELL_TASK_NAME , CreatWorkflowData.SHELL_TASK_NAME); @@ -55,11 +53,9 @@ public class CreateWorkflowPage extends PageCommon { //click stop run type clickElement(CreateWorkflowLocator.CLICK_STOP_RUN_TYPE); - //click normal run type clickElement(CreateWorkflowLocator.CLICK_NORMAL_RUN_TYPE); - //input shell task description sendInput(CreateWorkflowLocator.INPUT_SHELL_TASK_DESCRIPTION , CreatWorkflowData.SHELL_TASK_DESCRIPTION); @@ -93,15 +89,48 @@ public class CreateWorkflowPage extends PageCommon { //select timeout alarm clickElement(CreateWorkflowLocator.SELECT_TIMEOUT_ALARM); - //clear input + //clear timeout + clearInput(CreateWorkflowLocator.SELECT_TIMEOUT); clearInput(CreateWorkflowLocator.SELECT_TIMEOUT); - Thread.sleep(TestConstant.ONE_THOUSANG); //input timeout sendInput(CreateWorkflowLocator.SELECT_TIMEOUT,CreatWorkflowData.INPUT_TIMEOUT); - //input script - sendInput(CreateWorkflowLocator.INPUT_SCRIPT, CreatWorkflowData.SHELL_SCRIPT); + //click codeMirror and input script + inputCodeMirror(CreateWorkflowLocator.CLICK_CODE_MIRROR, CreateWorkflowLocator.INPUT_SCRIPT,CreatWorkflowData.SHELL_SCRIPT); + scrollToElementBottom(); + Thread.sleep(TestConstant.ONE_THOUSANG); + + //click custom parameters + clickElement(CreateWorkflowLocator.CLICK_CUSTOM_PARAMETERS); + + //input custom parameters + sendInput(CreateWorkflowLocator.INPUT_CUSTOM_PARAMETERS, CreatWorkflowData.INPUT_CUSTOM_PARAMETERS); + + //input custom parameters value + sendInput(CreateWorkflowLocator.INPUT_CUSTOM_PARAMETERS_VALUE, CreatWorkflowData.INPUT_CUSTOM_PARAMETERS_VALUE); + + //click add custom parameters + clickElement(CreateWorkflowLocator.CLICK_ADD_CUSTOM_PARAMETERS); + + scrollToElementBottom(); + Thread.sleep(TestConstant.ONE_THOUSANG); + + //input add custom parameters + sendInput(CreateWorkflowLocator.INPUT_ADD_CUSTOM_PARAMETERS,CreatWorkflowData.INPUT_ADD_CUSTOM_PARAMETERS); + + //input add custom parameters value + sendInput(CreateWorkflowLocator.INPUT_ADD_CUSTOM_PARAMETERS_VALUE,CreatWorkflowData.INPUT_ADD_CUSTOM_PARAMETERS_VALUE); + + //click delete custom parameters + clickElement(CreateWorkflowLocator.CLICK_DELETE_CUSTOM_PARAMETERS); + Thread.sleep(TestConstant.ONE_THOUSANG); + + //click submit button + clickElement(CreateWorkflowLocator.CLICK_SUBMIT_BUTTON); + Thread.sleep(TestConstant.ONE_THOUSANG); + + moveToDragElement(CreateWorkflowLocator.MOUSE_MOVE_SHELL_AT_DAG,-300,-100); return ifTitleContains(CreatWorkflowData.WORKFLOW_TITLE); } diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/testcase/project/CreateProjectTest.java b/e2e/src/test/java/org/apache/dolphinscheduler/testcase/project/CreateProjectTest.java index 66af10543b..8abd09d37c 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/testcase/project/CreateProjectTest.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/testcase/project/CreateProjectTest.java @@ -27,7 +27,7 @@ public class CreateProjectTest extends BaseTest { public void testUserManage() throws InterruptedException { createProjectPage = new CreateProjectPage(driver); // enter user manage page - createProjectPage.jumpPage(); + createProjectPage.jumpProjectManagePage(); //assert user manage page assert createProjectPage.createProject(); } diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/testcase/project/CreateWorkflowTest.java b/e2e/src/test/java/org/apache/dolphinscheduler/testcase/project/CreateWorkflowTest.java index ac1bfec69f..6ac13f8124 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/testcase/project/CreateWorkflowTest.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/testcase/project/CreateWorkflowTest.java @@ -17,18 +17,21 @@ package org.apache.dolphinscheduler.testcase.project; import org.apache.dolphinscheduler.base.BaseTest; +import org.apache.dolphinscheduler.page.project.CreateProjectPage; import org.apache.dolphinscheduler.page.project.CreateWorkflowPage; import org.testng.annotations.Test; public class CreateWorkflowTest extends BaseTest { private CreateWorkflowPage createWorkflowPage; + private CreateProjectPage createProjectPage; + @Test(description = "CreateWorkflowTest", priority = 1) public void CreateWorkflowTest() throws InterruptedException { + createProjectPage = new CreateProjectPage(driver); + createProjectPage.jumpProjectManagePage(); createWorkflowPage = new CreateWorkflowPage(driver); - // enter user manage page -// createWorkflowPage.jumpPage(); - //assert user manage page - assert createWorkflowPage.CreateWorkflow(); + //assert create workflow + assert createWorkflowPage.createWorkflow(); } }