From 00e0003aed207adc33d1c4068977b172fa21d3f0 Mon Sep 17 00:00:00 2001 From: xingchun-chen <55787491+xingchun-chen@users.noreply.github.com> Date: Tue, 18 Aug 2020 17:27:36 +0800 Subject: [PATCH] [test-2995][e2e]Add task connection (#3524) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add task connection  * Optimize test cases   * Modify variable format     * Optimize test cases   * Update BrowserCommon.java * Update BrowserCommon.java * Update WorkflowDefineLocator.java Co-authored-by: chenxingchun <438044805@qq.com> --- .../common/BrowserCommon.java | 40 +++++++++++++++---- .../project/WorkflowDefineLocator.java | 12 +++++- .../page/project/WorkflowDefinePage.java | 5 +++ 3 files changed, 48 insertions(+), 9 deletions(-) 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 437e81cfbb..2eade95488 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/common/BrowserCommon.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/common/BrowserCommon.java @@ -223,22 +223,46 @@ public class BrowserCommon { /** * mouse drag element * - * @param source_locator BY - * @param target_locator BY + * @param sourceLocator BY + * @param targetLocator BY */ - public void dragAndDrop(By source_locator, By target_locator) { - WebElement sourceElement = locateElement(source_locator); - WebElement targetElement = locateElement(target_locator); + public void dragAndDrop(By sourceLocator, By targetLocator) { + WebElement sourceElement = locateElement(sourceLocator); + WebElement targetElement = locateElement(targetLocator); actions.dragAndDrop(sourceElement, targetElement).perform(); actions.release(); } - public void moveToDragElement(By target_locator, int X, int Y) { - WebElement targetElement = locateElement(target_locator); - actions.dragAndDropBy(targetElement, X, Y).perform(); + public void moveToDragElement(By targetLocator, int x, int y) { + WebElement targetElement = locateElement(targetLocator); + actions.dragAndDropBy(targetElement, x, y).perform(); actions.release(); } + /** + * Right mouse click on the element + * + * @param locator By + * @return actions + */ + public void mouseRightClickElement(By locator) { + WebElement mouseRightClickElement = locateElement(locator); + actions.contextClick(mouseRightClickElement).perform(); + } + + /** + * The mouse moves from a position to a specified positionØ + * + * @param sourceLocator BY + * @param targetLocator BY + * @return actions + */ + public void mouseMovePosition(By sourceLocator, By targetLocator) throws InterruptedException { + WebElement sourceElement = locateElement(sourceLocator); + WebElement targetElement = locateElement(targetLocator); + actions.dragAndDrop(sourceElement,targetElement).perform(); + actions.click(); + } /** * jump page diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/locator/project/WorkflowDefineLocator.java b/e2e/src/test/java/org/apache/dolphinscheduler/locator/project/WorkflowDefineLocator.java index bfb237ccd2..a70b22eacf 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/locator/project/WorkflowDefineLocator.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/locator/project/WorkflowDefineLocator.java @@ -120,12 +120,22 @@ public class WorkflowDefineLocator { //click submit button public static final By CLICK_SUBMIT_BUTTON = By.xpath("//div[3]/div/button[2]/span"); + //copy task + public static final By MOUSE_RIGHT_CLICK = By.xpath("//div[2]/div[2]/div/div/div/div/div[2]"); + public static final By COPY_TASK = By.xpath("//a[3]/span"); + + //click line + public static final By CLICK_LINE = By.xpath("//a[@id='line']/button/i"); + + public static final By LINE_SOURCES_TASK = By.xpath("//div[@id='canvas']/div[1]/div[2]"); + + public static final By LINE_TARGET_TASK = By.xpath("//div[@id='canvas']/div[2]/div[2]"); /** * save workflow */ //click save workflow button - public static final By CLICK_SAVE_WORKFLOW_BUTTON = By.xpath("//div[2]/div[1]/div[2]/button[2]"); + public static final By CLICK_SAVE_WORKFLOW_BUTTON = By.xpath("//div[2]/div[1]/div[2]/button[2]/span"); //input workflow name public static final By INPUT_WORKFLOW_NAME = By.xpath("//input"); diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/page/project/WorkflowDefinePage.java b/e2e/src/test/java/org/apache/dolphinscheduler/page/project/WorkflowDefinePage.java index 9e462805da..83442562ca 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/page/project/WorkflowDefinePage.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/page/project/WorkflowDefinePage.java @@ -131,6 +131,11 @@ public class WorkflowDefinePage extends PageCommon { System.out.println("move to Dag Element "); moveToDragElement(WorkflowDefineLocator.MOUSE_MOVE_SHELL_AT_DAG,-300,-100); + System.out.println("copy task"); + mouseRightClickElement(WorkflowDefineLocator.MOUSE_RIGHT_CLICK); + clickButton(WorkflowDefineLocator.COPY_TASK); + clickButton(WorkflowDefineLocator.CLICK_LINE); + mouseMovePosition(WorkflowDefineLocator.LINE_SOURCES_TASK,WorkflowDefineLocator.LINE_TARGET_TASK); return ifTitleContains(WorkflowDefineData.CREATE_WORKFLOW_TITLE); }