Ejemplo n.º 1
0
def STEP(stepNo, desc):
    """


    stepNo:
    desc:
    """
    logger.info(f'\n-- 第 {stepNo} 步 -- {desc} \n', True, True)
Ejemplo n.º 2
0
def INFO(info):
    """
    在运行终端和测试报告中打印 重要信息,
    使得 运行报告更加清晰

    参数:
    info :   信息描述
    """
    logger.info(f'{info}', True, True)
Ejemplo n.º 3
0
def STEP(stepNo, desc):
    """
    在运行终端和测试报告中打印出 测试步骤说明,
    使得 运行报告更加清晰

    参数:
    stepNo : 指定 是第几步
    desc :   步骤描述
    """
    logger.info(f'\n-- 第 {stepNo} 步 -- {desc} \n', True, True)
Ejemplo n.º 4
0
def CHECK_POINT(desc, condition):
    """
    检查点

    参数:
    desc :   检查点文字描述
    condition : 检查点 表达式
    """
    logger.info(f'\n** 检查点 **  {desc} ', True, True)

    if condition:
        logger.info('---->  通过\n', True, True)
    else:
        logger.info('---->   !! 不通过!!\n', True, True)
        raise AssertionError(f'\n** 检查点不通过 **  {desc} ')


# def CHECK_POINT2(desc, conditionRet):
#     print(f'\n\033[34m** 检查点 **  {desc} \033[0m')
#
#     if conditionRet:
#         print('\033[32m---->  通过 \033[0m')
#     else:
#         print('\033[31m---->   !! 不通过!! \033[0m')
#         raise AssertionError(f'\n** 检查点不通过 **  {desc} ' )
Ejemplo n.º 5
0
def CHECK_POINT(desc, condition):
    """

    desc:
    condition:
    """

    logger.info(f'\n *** 检查点 *** {desc} \n', True, True)
    if condition:
        logger.info('-->通过')
    else:
        logger.info(' -->不通过', True, True)
        raise AssertionError(f'*** 检查点不通过*** {desc}')
Ejemplo n.º 6
0
def CHECK_POINT(desc, condition):
    """
    检查点

    参数:
    desc :   检查点文字描述
    condition : 检查点 表达式
    """
    logger.info(f'\n** 检查点 **  {desc} ', True, True)

    if condition:
        logger.info('---->  通过\n', True, True)
    else:
        logger.info('---->   !! 不通过!!\n', True, True)
        raise AssertionError(f'\n** 检查点不通过 **  {desc} ')
Ejemplo n.º 7
0
def broswer_client(username, password):
    try:
        logger.info(f'\n{username}:-- 第 {1} 步 -- {"登陆网站"} \n', True, True)
        wd = webdriver.Chrome()
        # 调用WebDriver 对象的get方法 可以让浏览器打开指定网址
        wd.get('http://218.240.148.68:56717/web/index.jsp')
        wd.implicitly_wait(30)
        wd.find_element_by_id('_easyui_textbox_input1').send_keys(username)
        time.sleep(2)
        wd.find_element_by_id('_easyui_textbox_input2').send_keys(password)
        time.sleep(2)
        wd.find_element_by_xpath('//*[@type="button"]').click()
        logger.info(f'\n{username}:-- 第 {2} 步 -- {"遍历访问左边导航菜单"} \n', True, True)
        elements = wd.find_elements_by_xpath("//div[@class='panel-title panel-with-icon']")
        for i,e in enumerate(elements):
            if i == 0:
                continue
            e.click()
            time.sleep(2)

        logger.info(f'\n{username}:-- 第 {3} 步 -- {"遍历访问左边导航菜单"} \n', True, True)
        elements = wd.find_elements_by_xpath("//li/div")
        for i,e in enumerate(elements):
            if i >= 16:
                break
            e.click()
            time.sleep(2)

        logger.info(f'\n{username}:-- 第 {4} 步 -- {"打开一个设备"} \n', True, True)
        element = wd.find_element_by_id("_easyui_tree_2").click()
        time.sleep(2)
        wd.switch_to.frame(wd.find_elements_by_tag_name("iframe")[15])
        time.sleep(2)
        elements = wd.find_elements_by_xpath('''//td[@field="unitId"]/div/a''')
        elements[0].click()

        logger.info(f'\n{username}:-- 第 {5} 步 -- {"10秒钟后关闭浏览器"} \n', True, True)
        time.sleep(10)
        wd.close()
        logger.info(f'\n{username}:-- 第 {6} 步 -- {"测试成功"} \n', True, True)
    except:
        logger.info('---->   !! 不通过!!\n', True, True)
        raise AssertionError(f'\n** 检查点不通过 **  {username} : 访问抛出异常  ')