01新增区域功能.py 2.5 KB
Newer Older
1 2
import sys
import os
3

4
from hytest.common import SELENIUM_LOG_SCREEN
5

6 7
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', '..')))
from 运维集控.项目测试.运维标准版.lib.base import *
彭甘宇's avatar
彭甘宇 committed
8

9 10 11 12 13 14 15
# 构建 CSV 文件的绝对路径
csv_path = os.path.abspath(
    os.path.join(os.path.dirname(__file__), '..', '..', 'testdata', '05区域功能', '新增区域功能.csv'))

class AreafuntionAdd:
    tag = ['新增区域功能']
    ddt_cases = read_csv_data(csv_path)
彭甘宇's avatar
彭甘宇 committed
16 17 18
    def teststeps(self):
        wd = GSTORE['wd']

19 20 21 22
        #从self.para中解构出数据
        name = self.name
        funtion_name, sort, remark, info= self.para

彭甘宇's avatar
彭甘宇 committed
23 24
        STEP(1, '点击新增按钮')
        areafuntion_add = WebDriverWait(wd, 10).until(
25 26
            EC.element_to_be_clickable(
                (By.XPATH, "//div[@class='company-edmit-right']//span[contains(text(),'新增')]"))
彭甘宇's avatar
彭甘宇 committed
27 28
        )
        areafuntion_add.click()
29
        sleep(1)
彭甘宇's avatar
彭甘宇 committed
30

31 32 33 34
        STEP(2, f'填写功能名称:{funtion_name}')
        funtion_name_input = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located(
                (By.XPATH, "//div[@class='el-input el-input--suffix']//input[@placeholder='请输入功能名称']"))
彭甘宇's avatar
彭甘宇 committed
35
        )
36 37
        funtion_name_input.clear()
        funtion_name_input.send_keys(funtion_name)
彭甘宇's avatar
彭甘宇 committed
38

39
        STEP(3, f'填写排序:{sort}')
彭甘宇's avatar
彭甘宇 committed
40
        funtion_sort = WebDriverWait(wd, 10).until(
41 42
            EC.presence_of_element_located(
                (By.XPATH, "//input[@placeholder='排序']"))
彭甘宇's avatar
彭甘宇 committed
43 44
        )
        funtion_sort.clear()
45
        funtion_sort.send_keys(sort)
彭甘宇's avatar
彭甘宇 committed
46

47
        STEP(4, f'填写备注:{remark}')
彭甘宇's avatar
彭甘宇 committed
48 49 50 51 52
        funtion_remark = WebDriverWait(wd, 10).until(
            EC.presence_of_element_located(
                (By.XPATH, "//input[@placeholder='备注']"))
        )
        funtion_remark.clear()
53
        funtion_remark.send_keys(remark)
彭甘宇's avatar
彭甘宇 committed
54 55 56

        STEP(5, '点击确认')
        commit = WebDriverWait(wd, 10).until(
57 58
            EC.element_to_be_clickable(
                (By.XPATH, "//div[@class='dialog-footer']//span[contains(text(),'确 定')]"))
彭甘宇's avatar
彭甘宇 committed
59 60 61 62 63
        )
        commit.click()

        STEP(6, '验证是否新增成功')
        get_menu = WebDriverWait(wd, 10).until(
64 65
            EC.visibility_of_element_located(
                (By.CSS_SELECTOR, '.el-message__content'))
彭甘宇's avatar
彭甘宇 committed
66 67
        )
        get_menu1 = get_menu.text
68 69 70
        CHECK_POINT('检查是否出现成功提示弹窗', get_menu1 == info)

        # 截图并保存
71
        SELENIUM_LOG_SCREEN(wd, "50%")
72 73
        sleep(1)
        wd.refresh()