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

class AreafuntionAdd001:
    name = 'Areafuntion_add_001'
    def teststeps(self):
        wd = GSTORE['wd']

        STEP(1, '点击新增按钮')
        areafuntion_add = WebDriverWait(wd, 10).until(
            EC.element_to_be_clickable((By.XPATH, "//div[@class='company-edmit-right']//span[contains(text(),'新增')]"))
        )
        areafuntion_add.click()
        sleep(2)

        STEP(2, '填写功能名称')
        funtion_name = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located((By.XPATH, "//div[@class='el-input el-input--suffix']//input[@placeholder='请输入功能名称']"))
        )
        funtion_name.clear()
        funtion_name.send_keys("测试功能1")

        STEP(3, '填写排序')
        funtion_sort = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located((By.XPATH, "//input[@placeholder='排序']"))
        )
        funtion_sort.clear()
        funtion_sort.send_keys("123")

        STEP(4, '填写备注')
        funtion_remark = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located(
                (By.XPATH, "//input[@placeholder='备注']"))
        )
        funtion_remark.clear()
        funtion_remark.send_keys("功能备注测试")

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

        STEP(6, '验证是否新增成功')
        get_menu = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located((By.CSS_SELECTOR, '.el-message__content'))
        )
        get_menu1 = get_menu.text
        CHECK_POINT('检查是否出现成功提示弹窗', get_menu1 == "操作成功!")
        sleep(2)