TokenManagePage.java 3.2 KB
Newer Older
X
xingchun-chen 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*
 * 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.security;

import org.apache.dolphinscheduler.common.PageCommon;
import org.apache.dolphinscheduler.data.security.TokenManageData;
import org.apache.dolphinscheduler.locator.security.TokenManageLocator;
import org.openqa.selenium.WebDriver;

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

    /**
30
     * create token
X
xingchun-chen 已提交
31
     *
32
     * @return Whether to enter the specified page after create tenant
X
xingchun-chen 已提交
33 34 35 36
     */
    public boolean createToken() throws InterruptedException {
        //create token
        clickElement(TokenManageLocator.CLICK_TOKEN_MANAGE);
37 38 39

        //determine whether the create token button exists
        ifTextExists(TokenManageLocator.CLICK_CREATE_TOKEN,TokenManageData.CREATE_TOKEN);
X
xingchun-chen 已提交
40 41 42 43 44 45 46

        // click  create token button
        clickButton(TokenManageLocator.CLICK_CREATE_TOKEN);

        clickButton(TokenManageLocator.SELECT_USER);

        clickButton(TokenManageLocator.CLICK_GENERATE_TOKEN_BUTTON);
47
        Thread.sleep(2000);
X
xingchun-chen 已提交
48 49 50 51 52 53 54 55

        // click  button
        clickButton(TokenManageLocator.CLICK_SUBMIT_BUTTON);

        // Whether to enter the specified page after submit
        return ifTitleContains(TokenManageData.TOKEN_MANAGE);
    }

56 57 58 59 60
    /**
     * edit token
     *
     * @return Whether to enter the specified page after edit tenant
     */
X
xingchun-chen 已提交
61
    public boolean editToken() throws InterruptedException {
62 63
        // edit token
        ifTextExists(TokenManageLocator.TOKEN, "1");
X
xingchun-chen 已提交
64

65 66 67 68
        // determine the existence of the editing token
        locateElement(TokenManageLocator.EDIT_TOKEN_BUTTON);

        // click  edit token button
X
xingchun-chen 已提交
69 70 71 72 73
        clickButton(TokenManageLocator.CLICK_EDIT_BUTTON);

        clickButton(TokenManageLocator.SELECT_USER);

        clickButton(TokenManageLocator.CLICK_GENERATE_TOKEN_BUTTON);
74
        Thread.sleep(2000);
X
xingchun-chen 已提交
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95

        // click  button
        clickButton(TokenManageLocator.CLICK_SUBMIT_BUTTON);

        // Whether to enter the specified page after submit
        return ifTitleContains(TokenManageData.TOKEN_MANAGE);
    }


    //delete token
    public boolean deleteToken() throws InterruptedException {
        // click  token manage
        clickElement(TokenManageLocator.CLICK_TOKEN_MANAGE);

        clickButton(TokenManageLocator.CLICK_DELETE_BUTTON);
        clickButton(TokenManageLocator.CLICK_CONFIRM_DELETE_BUTTON);

        return ifTitleContains(TokenManageData.TOKEN_MANAGE);
    }

}