from lib.login 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.click()
        sleep(2)

        STEP(2, '填写登录名')
        account_input = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located((By.XPATH, "//input[@placeholder='请输入用户名称']"))
        )
        account_input.clear()
        account_input.send_keys("admin@test1")

        STEP(3, '勾选用户')
        select_click= WebDriverWait(wd, 10).until(
            EC.presence_of_element_located((By.XPATH, "//tbody//tr//td//div//label//span//span"))
        )
        select_click.click()
        sleep(2)

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

        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 == "操作成功!")
        sleep(2)

        # 本地启动http微服务
        # python - m http.server 80 - -directory log
        # 输出报告到钉钉
        get_reportfile_send_dingding("用户管理模块_测试报告", "http://192.168.1.251")