未验证 提交 f407adcb 编写于 作者: X xingchun-chen 提交者: GitHub

Add e2e to create workflow case   (#2027)

* 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: Nchenxingchun <50446296+chenxingchun@users.noreply.github.com>
上级 ee3c0aed
...@@ -27,6 +27,7 @@ import java.io.IOException; ...@@ -27,6 +27,7 @@ import java.io.IOException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.openqa.selenium.PageLoadStrategy; import org.openqa.selenium.PageLoadStrategy;
/** /**
* base driver class * base driver class
*/ */
...@@ -97,8 +98,13 @@ public class BaseDriver { ...@@ -97,8 +98,13 @@ public class BaseDriver {
/* driver setting wait time */ /* driver setting wait time */
// implicitly wait time // implicitly wait time
driver.manage().timeouts().implicitlyWait(implicitlyWait, TimeUnit.SECONDS); driver.manage().timeouts().implicitlyWait(implicitlyWait, TimeUnit.SECONDS);
// page load timeout
driver.manage().timeouts().pageLoadTimeout(pageLoadTimeout, TimeUnit.SECONDS);
// page load timeout // page load timeout
driver.manage().timeouts().pageLoadTimeout(pageLoadTimeout, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(pageLoadTimeout, TimeUnit.SECONDS);
// script timeout // script timeout
driver.manage().timeouts().setScriptTimeout(setScriptTimeout, TimeUnit.SECONDS); driver.manage().timeouts().setScriptTimeout(setScriptTimeout, TimeUnit.SECONDS);
......
...@@ -99,8 +99,6 @@ public class BrowserCommon { ...@@ -99,8 +99,6 @@ public class BrowserCommon {
// show wait timeout // show wait timeout
long timeout = Long.valueOf(PropertiesReader.getKey("driver.timeouts.webDriverWait")); long timeout = Long.valueOf(PropertiesReader.getKey("driver.timeouts.webDriverWait"));
wait = new WebDriverWait(driver, timeout); wait = new WebDriverWait(driver, timeout);
// this.redisUtil = redisUtil;
// this.jedis = redisUtil.getJedis();
} }
...@@ -158,22 +156,34 @@ public class BrowserCommon { ...@@ -158,22 +156,34 @@ public class BrowserCommon {
* *
* @param locator By * @param locator By
*/ */
public void clearInput(By locator) { public WebElement clearInput(By locator) {
WebElement clearElement = locateElement(locator); WebElement clearElement = locateElement(locator);
clearElement.click(); clearElement.click();
clearElement.clear();
clearElement.sendKeys(Keys.chord(Keys.CONTROL, "a")); 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 * move to element
*
* @param locator BY * @param locator BY
* @return actions * @return actions
*/ */
public Actions moveToElement(By locator) { public Actions moveToElement(By locator){
return actions.moveToElement(locateElement(locator)); return actions.moveToElement(locateElement(locator));
} }
...@@ -182,13 +192,17 @@ public class BrowserCommon { ...@@ -182,13 +192,17 @@ public class BrowserCommon {
* *
* @param source_locator BY * @param source_locator BY
* @param target_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) { public void dragAndDrop(By source_locator, By target_locator){
WebElement sourcetElement = locateElement(source_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); WebElement targetElement = locateElement(target_locator);
actions.dragAndDrop(sourcetElement, targetElement).moveToElement(targetElement, X, Y).perform(); actions.dragAndDropBy(targetElement, X, Y).perform();
actions.release(); actions.release();
} }
...@@ -300,6 +314,13 @@ public class BrowserCommon { ...@@ -300,6 +314,13 @@ public class BrowserCommon {
executeScript("window.scrollTo(0, document.body.scrollHeight)"); 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 * Page swipe makes the top of the element align with the top of the page
* *
......
...@@ -29,8 +29,18 @@ public class CreatWorkflowData { ...@@ -29,8 +29,18 @@ public class CreatWorkflowData {
//input shell script //input shell script
public static final String SHELL_SCRIPT = "echo 1111111"; 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";
} }
...@@ -20,9 +20,6 @@ package org.apache.dolphinscheduler.locator.project; ...@@ -20,9 +20,6 @@ package org.apache.dolphinscheduler.locator.project;
import org.openqa.selenium.By; import org.openqa.selenium.By;
public class CreateWorkflowLocator { public class CreateWorkflowLocator {
// click project manage
public static final By CLICK_PROJECT_MANAGE = By.xpath("//div[2]/div/a/span");
// click project name // click project name
public static final By CLICK_PROJECT_NAME = By.xpath("//span/a"); public static final By CLICK_PROJECT_NAME = By.xpath("//span/a");
...@@ -33,16 +30,13 @@ public class CreateWorkflowLocator { ...@@ -33,16 +30,13 @@ public class CreateWorkflowLocator {
public static final By CLICK_CREATE_WORKFLOW_BUTTON = By.xpath("//button/span"); public static final By CLICK_CREATE_WORKFLOW_BUTTON = By.xpath("//button/span");
//mouse down at shell //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 //mouse down at spark
public static final By MOUSE_DOWN_AT_SPARK = By.xpath("//div[5]/div/div"); public static final By MOUSE_DOWN_AT_SPARK = By.xpath("//div[5]/div/div");
//mouse move at DAG //mouse move at DAG
public static final By MOUSE_MOVE_SHELL_AT_DAG = 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']");
// //click shell task
// public static final By CLICK_SHELL_TASK = By.xpath("//div[2]/div/div[2]/div[2]/div/div");
//input shell task _name //input shell task _name
public static final By INPUT_SHELL_TASK_NAME = By.xpath("//input"); public static final By INPUT_SHELL_TASK_NAME = By.xpath("//input");
...@@ -89,9 +83,33 @@ public class CreateWorkflowLocator { ...@@ -89,9 +83,33 @@ public class CreateWorkflowLocator {
//input timeout //input timeout
public static final By SELECT_TIMEOUT = By.xpath("//div[3]/div[2]/label/div/input"); 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 //input script
public static final By INPUT_SCRIPT = By.xpath("//div[2]/div/div/div/div/div/textarea"); 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");
} }
...@@ -29,9 +29,10 @@ public class CreateProjectPage extends PageCommon { ...@@ -29,9 +29,10 @@ public class CreateProjectPage extends PageCommon {
/** /**
* jump page * jump page
*/ */
public void jumpPage() throws InterruptedException { public void jumpProjectManagePage() throws InterruptedException {
Thread.sleep(TestConstant.ONE_THOUSANG); Thread.sleep(TestConstant.ONE_THOUSANG);
clickElement(CreateProjectLocator.PROJECT_MANAGE); clickElement(CreateProjectLocator.PROJECT_MANAGE);
Thread.sleep(TestConstant.ONE_THOUSANG);
} }
/** /**
...@@ -40,7 +41,6 @@ public class CreateProjectPage extends PageCommon { ...@@ -40,7 +41,6 @@ public class CreateProjectPage extends PageCommon {
* @return Whether to enter the specified page after creat tenant * @return Whether to enter the specified page after creat tenant
*/ */
public boolean createProject() throws InterruptedException { public boolean createProject() throws InterruptedException {
Thread.sleep(TestConstant.ONE_THOUSANG);
//click create project //click create project
clickElement(CreateProjectLocator.CREATE_PROJECT_BUTTON); clickElement(CreateProjectLocator.CREATE_PROJECT_BUTTON);
Thread.sleep(TestConstant.ONE_THOUSANG); Thread.sleep(TestConstant.ONE_THOUSANG);
......
...@@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.page.project; ...@@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.page.project;
import org.apache.dolphinscheduler.common.PageCommon; import org.apache.dolphinscheduler.common.PageCommon;
import org.apache.dolphinscheduler.constant.TestConstant; import org.apache.dolphinscheduler.constant.TestConstant;
import org.apache.dolphinscheduler.data.project.CreatWorkflowData; import org.apache.dolphinscheduler.data.project.CreatWorkflowData;
import org.apache.dolphinscheduler.locator.project.CreateProjectLocator;
import org.apache.dolphinscheduler.locator.project.CreateWorkflowLocator; import org.apache.dolphinscheduler.locator.project.CreateWorkflowLocator;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
...@@ -30,24 +29,23 @@ public class CreateWorkflowPage extends PageCommon { ...@@ -30,24 +29,23 @@ public class CreateWorkflowPage extends PageCommon {
/** /**
* jump page * 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 // click project name
clickElement(CreateWorkflowLocator.CLICK_PROJECT_NAME); clickElement(CreateWorkflowLocator.CLICK_PROJECT_NAME);
Thread.sleep(TestConstant.ONE_THOUSANG); Thread.sleep(TestConstant.ONE_THOUSANG);
// click workflow define // click workflow define
clickElement(CreateWorkflowLocator.CLICK_WORKFLOW_DEFINE); clickElement(CreateWorkflowLocator.CLICK_WORKFLOW_DEFINE);
Thread.sleep(TestConstant.ONE_THOUSANG);
// click create workflow button // click create workflow button
clickElement(CreateWorkflowLocator.CLICK_CREATE_WORKFLOW_BUTTON); clickElement(CreateWorkflowLocator.CLICK_CREATE_WORKFLOW_BUTTON);
Thread.sleep(TestConstant.ONE_THOUSANG);
//drag shell_task //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 //input shell task _name
sendInput(CreateWorkflowLocator.INPUT_SHELL_TASK_NAME , CreatWorkflowData.SHELL_TASK_NAME); sendInput(CreateWorkflowLocator.INPUT_SHELL_TASK_NAME , CreatWorkflowData.SHELL_TASK_NAME);
...@@ -55,11 +53,9 @@ public class CreateWorkflowPage extends PageCommon { ...@@ -55,11 +53,9 @@ public class CreateWorkflowPage extends PageCommon {
//click stop run type //click stop run type
clickElement(CreateWorkflowLocator.CLICK_STOP_RUN_TYPE); clickElement(CreateWorkflowLocator.CLICK_STOP_RUN_TYPE);
//click normal run type //click normal run type
clickElement(CreateWorkflowLocator.CLICK_NORMAL_RUN_TYPE); clickElement(CreateWorkflowLocator.CLICK_NORMAL_RUN_TYPE);
//input shell task description //input shell task description
sendInput(CreateWorkflowLocator.INPUT_SHELL_TASK_DESCRIPTION , CreatWorkflowData.SHELL_TASK_DESCRIPTION); sendInput(CreateWorkflowLocator.INPUT_SHELL_TASK_DESCRIPTION , CreatWorkflowData.SHELL_TASK_DESCRIPTION);
...@@ -93,15 +89,48 @@ public class CreateWorkflowPage extends PageCommon { ...@@ -93,15 +89,48 @@ public class CreateWorkflowPage extends PageCommon {
//select timeout alarm //select timeout alarm
clickElement(CreateWorkflowLocator.SELECT_TIMEOUT_ALARM); clickElement(CreateWorkflowLocator.SELECT_TIMEOUT_ALARM);
//clear input //clear timeout
clearInput(CreateWorkflowLocator.SELECT_TIMEOUT);
clearInput(CreateWorkflowLocator.SELECT_TIMEOUT); clearInput(CreateWorkflowLocator.SELECT_TIMEOUT);
Thread.sleep(TestConstant.ONE_THOUSANG);
//input timeout //input timeout
sendInput(CreateWorkflowLocator.SELECT_TIMEOUT,CreatWorkflowData.INPUT_TIMEOUT); sendInput(CreateWorkflowLocator.SELECT_TIMEOUT,CreatWorkflowData.INPUT_TIMEOUT);
//input script //click codeMirror and input script
sendInput(CreateWorkflowLocator.INPUT_SCRIPT, CreatWorkflowData.SHELL_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); return ifTitleContains(CreatWorkflowData.WORKFLOW_TITLE);
} }
......
...@@ -27,7 +27,7 @@ public class CreateProjectTest extends BaseTest { ...@@ -27,7 +27,7 @@ public class CreateProjectTest extends BaseTest {
public void testUserManage() throws InterruptedException { public void testUserManage() throws InterruptedException {
createProjectPage = new CreateProjectPage(driver); createProjectPage = new CreateProjectPage(driver);
// enter user manage page // enter user manage page
createProjectPage.jumpPage(); createProjectPage.jumpProjectManagePage();
//assert user manage page //assert user manage page
assert createProjectPage.createProject(); assert createProjectPage.createProject();
} }
......
...@@ -17,18 +17,21 @@ ...@@ -17,18 +17,21 @@
package org.apache.dolphinscheduler.testcase.project; package org.apache.dolphinscheduler.testcase.project;
import org.apache.dolphinscheduler.base.BaseTest; import org.apache.dolphinscheduler.base.BaseTest;
import org.apache.dolphinscheduler.page.project.CreateProjectPage;
import org.apache.dolphinscheduler.page.project.CreateWorkflowPage; import org.apache.dolphinscheduler.page.project.CreateWorkflowPage;
import org.testng.annotations.Test; import org.testng.annotations.Test;
public class CreateWorkflowTest extends BaseTest { public class CreateWorkflowTest extends BaseTest {
private CreateWorkflowPage createWorkflowPage; private CreateWorkflowPage createWorkflowPage;
private CreateProjectPage createProjectPage;
@Test(description = "CreateWorkflowTest", priority = 1) @Test(description = "CreateWorkflowTest", priority = 1)
public void CreateWorkflowTest() throws InterruptedException { public void CreateWorkflowTest() throws InterruptedException {
createProjectPage = new CreateProjectPage(driver);
createProjectPage.jumpProjectManagePage();
createWorkflowPage = new CreateWorkflowPage(driver); createWorkflowPage = new CreateWorkflowPage(driver);
// enter user manage page //assert create workflow
// createWorkflowPage.jumpPage(); assert createWorkflowPage.createWorkflow();
//assert user manage page
assert createWorkflowPage.CreateWorkflow();
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册