import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', '..')))
from 运维集控.项目测试.运维标准版.lib.base import *

class Userdelete001:
    name = 'user_delete_001'
    def teststeps(self):
        wd = GSTORE['wd']

        STEP(1, '点击搜索框')
        user_query = WebDriverWait(wd, 10).until(
            EC.element_to_be_clickable((By.XPATH, "//input[@placeholder='请输入用户名称']"))
        )
        user_query.clear()
        user_query.send_keys("test_user3")

        STEP(2, '勾选用户')
        select_click= WebDriverWait(wd, 10).until(
            EC.presence_of_element_located((By.XPATH, "//th[contains(@class,'is-leaf el-table__cell')]//span[contains(@class,'el-checkbox__inner')]"))
        )
        select_click.click()

        STEP(4, '点击删除按钮')
        user_update = WebDriverWait(wd, 10).until(
            EC.element_to_be_clickable((By.XPATH, "//span[contains(text(),'删除')]"))
        )
        user_update.click()

        STEP(5, '点击确认')
        commit = WebDriverWait(wd, 10).until(
            EC.element_to_be_clickable((By.XPATH, "//button[contains(@class,'el-button el-button--default el-button--small el-button--primary')]//span[contains(text(),'确 定')]"))
        )
        commit.click()

        STEP(6, '验证是否删除成功')
        get_menu = WebDriverWait(wd, 10).until(
            EC.visibility_of_element_located((By.XPATH, "//p[@class='el-message__content']"))
        )
        get_menu1 = get_menu.text
        CHECK_POINT('检查是否出现成功提示弹窗', get_menu1 == "操作成功!")

        # 截图并保存
        SELENIUM_LOG_SCREEN(wd, "50%")
        wd.refresh()
