from lib.login import *

class areafuntionMod001:
    name = 'areafuntion_mod_001'
    def teststeps(self):
        wd = GSTORE['wd']

        STEP(1, '搜索对应的区域功能')
        areafuntion_search= WebDriverWait(wd, 10).until(
            EC.element_to_be_clickable((By.XPATH, "(//input[contains(@placeholder,'请输入区域功能')])[1]"))
        )
        areafuntion_search.clear()
        areafuntion_search.send_keys("测试功能1")

        STEP(2, '勾选区域功能')
        areafuntion_select = WebDriverWait(wd, 10).until(
            EC.element_to_be_clickable((By.XPATH, "(//span[contains(@class,'el-checkbox__inner')])[2]"))
        )
        areafuntion_select.click()

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

        STEP(4, '修改区域功能内容')
        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(5, '修改排序')
        funtion_sort = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located((By.XPATH, "//input[@placeholder='排序']"))
        )
        funtion_sort.clear()
        funtion_sort.send_keys("999")

        STEP(6, '修改备注信息')
        funtion_remark = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located(
                (By.XPATH, "//input[@placeholder='备注']"))
        )
        funtion_remark.clear()
        funtion_remark.send_keys("修改-功能备注")

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

        STEP(8, '验证是否修改成功')
        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)