TimingPage.java 5.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.dolphinscheduler.page.project;

import org.apache.dolphinscheduler.common.PageCommon;
import org.apache.dolphinscheduler.data.project.TimingData;
21
import org.apache.dolphinscheduler.data.project.WorkflowDefineData;
22
import org.apache.dolphinscheduler.locator.project.TimingLocator;
23
import org.apache.dolphinscheduler.locator.project.WorkflowDefineLocator;
24 25 26 27 28 29 30 31 32 33 34 35
import org.openqa.selenium.WebDriver;

public class TimingPage extends PageCommon {
    public TimingPage(WebDriver driver) {
        super(driver);
    }


    /**
     * create timing
     */
    public boolean createTiming() throws InterruptedException {
36 37 38
        // Determine whether the workflow status is online
        ifTextExists(WorkflowDefineLocator.WORKFLOW_STATE, WorkflowDefineData.WORKFLOW_ONLINE_STATE);

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
        // click timing button
        System.out.println("Click timing button");
        clickButton(TimingLocator.CLICK_TIMING_BUTTON);
        System.out.println("Click execution timing button");
        clickButton(TimingLocator.CLICK_EXECUTION_TIMING_BUTTON);

        clickElement(TimingLocator.SELECT_FAILURE_STRATEGY_END);
        clickElement(TimingLocator.SELECT_FAILURE_STRATEGY_CONTINUE);
        clickElement(TimingLocator.CLICK_NOTICE_STRATEGY);
        clickElement(TimingLocator.SELECT_NOTICE_STRATEGY);
        clickElement(TimingLocator.CLICK_PROCESS_PRIORITY);
        clickElement(TimingLocator.SELECT_PROCESS_PRIORITY);
        clickElement(TimingLocator.CLICK_WORKER_GROUP);
        clickElement(TimingLocator.SELECT_WORKER_GROUP);
        clickElement(TimingLocator.CLICK_NOTICE_GROUP);
        clickElement(TimingLocator.SELECT_NOTICE_GROUP);
        sendInput(TimingLocator.INPUT_RECIPIENT, TimingData.RECIPIENT);
        sendInput(TimingLocator.INPUT_Cc,TimingData.Cc);
        clickButton(TimingLocator.CLICK_CREATE_BUTTON);

59
        return ifTextExists(TimingLocator.TIMING_STATE, TimingData.TIMING_OFFLINE_STATE);
60 61 62 63 64 65 66 67 68
    }

    /**
     * edit timing
     */
    public boolean editTiming() throws InterruptedException {
        // click timing button
        System.out.println("Click timing  management button");
        clickButton(TimingLocator.CLICK_TIMING_MANAGEMENT_BUTTON);
69 70 71 72

        // Determine whether the workflow name exists
        ifTextExists(TimingLocator.WORKFLOW_NAME, WorkflowDefineData.INPUT_WORKFLOW_NAME);

73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
        System.out.println("Click edit timing button");
        clickButton(TimingLocator.CLICK_EDIT_TIMING_BUTTON);
        System.out.println("Click execution timing button");
        clickButton(TimingLocator.CLICK_EXECUTION_TIMING_BUTTON);

        clickElement(TimingLocator.SELECT_FAILURE_STRATEGY_END);
        clickElement(TimingLocator.SELECT_FAILURE_STRATEGY_CONTINUE);
        clickElement(TimingLocator.CLICK_NOTICE_STRATEGY);
        clickElement(TimingLocator.SELECT_NOTICE_STRATEGY);
        clickElement(TimingLocator.CLICK_PROCESS_PRIORITY);
        clickElement(TimingLocator.SELECT_PROCESS_PRIORITY);
        clickElement(TimingLocator.CLICK_WORKER_GROUP);
        clickElement(TimingLocator.SELECT_WORKER_GROUP);
        clickElement(TimingLocator.CLICK_NOTICE_GROUP);
        clickElement(TimingLocator.SELECT_NOTICE_GROUP);
        sendInput(TimingLocator.INPUT_RECIPIENT, TimingData.EDIT_RECIPIENT);
        sendInput(TimingLocator.INPUT_Cc,TimingData.EDIT_Cc);
        clickButton(TimingLocator.CLICK_CREATE_BUTTON);

        return ifTitleContains(TimingData.TIMING_TITLE );
    }


    /**
     * online timing
     */
    public boolean onlineTiming() throws InterruptedException {
100 101 102 103
        flushPage();
        // Determine whether the timing is offline
        ifTextExists(TimingLocator.TIMING_MANAGEMENT_TIMING_STATE, TimingData.TIMING_OFFLINE_STATE);

104 105
        // click online timing button
        System.out.println("Click online timing  button");
106
        clickElement(TimingLocator.CLICK_ONLINE_TIMING_BUTTON);
107

108
        return ifTextExists(TimingLocator.TIMING_MANAGEMENT_TIMING_STATE, TimingData.TIMING_ONLINE_STATE);
109 110 111 112 113 114 115
    }


    /**
     * offline timing
     */
    public boolean offlineTiming() throws InterruptedException {
116 117 118 119
        flushPage();
        // Determine whether the timing is online
        ifTextExists(TimingLocator.TIMING_MANAGEMENT_TIMING_STATE, TimingData.TIMING_ONLINE_STATE);

120 121
        // click offline timing button
        System.out.println("Click offline timing  button");
122
        clickElement(TimingLocator.CLICK_OFFLINE_TIMING_BUTTON);
123

124
        return ifTextExists(TimingLocator.TIMING_MANAGEMENT_TIMING_STATE, TimingData.TIMING_OFFLINE_STATE);
125 126 127 128 129 130 131 132
    }



    /**
     * delete timing
     */
    public boolean deleteTiming() throws InterruptedException {
133 134 135
        // Determine whether the timing is offline
        ifTextExists(TimingLocator.TIMING_MANAGEMENT_TIMING_STATE, TimingData.TIMING_OFFLINE_STATE);

136 137 138 139 140
        // click offline timing button
        System.out.println("Click delete timing  button");
        clickButton(TimingLocator.CLICK_DELETE_TIMING_BUTTON);
        clickButton(TimingLocator.CLICK_CONFIRM_DELETE_TIMING_BUTTON);

141
        return ifTextExists(TimingLocator.TIMING_STATE, "-");
142 143
    }
}