from lib.login import *

class AreatypeAdd001:
    name = 'Areatype_add_001'
    def teststeps(self):
        wd = GSTORE['wd']

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

        STEP(2, '填写区域类型')
        type_name = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located((By.XPATH, "//div[@class='el-input el-input--suffix']//input[@placeholder='请输入区域类型']"))
        )
        type_name.clear()
        type_name.send_keys("测试类型1")

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

        STEP(4, '填写备注')
        type_remark = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located(
                (By.XPATH, "//input[@placeholder='备注']"))
        )
        type_remark.clear()
        type_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)