from lib.login import *

class AreagroupAdd001:
    name = 'Areagroup_add_001'
    def teststeps(self):
        wd = GSTORE['wd']

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

        STEP(2, '填写分组名称')
        group_name = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located((By.XPATH, "//input[@placeholder='长度1-20个字符']"))
        )
        group_name.clear()
        group_name.send_keys("测试区域1")

        STEP(3, '填写分组地址')
        group_address = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located((By.XPATH, "//input[@placeholder='输入地址不能大于50个字符']"))
        )
        group_address.clear()
        group_address.send_keys("顺恒利大厦")

        STEP(4, '填写分组备注')
        group_remark = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located(
                (By.XPATH, "//input[@placeholder='请输入备注']"))
        )
        group_remark.clear()
        group_remark.send_keys("测试分组备注")

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

        STEP(7, '验证是否新增成功')
        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)