Exemple #1
0
def login_admin(request, driver):
    """用户登录"""
    log.info("用户登录")
    login = loginaction.Login(driver)
    login.login('15928009283', 'www123456.')

    def end():
        log.info("测试用例执行完成,登出系统")
        driver.origin_driver.delete_all_cookies()

    request.addfinalizer(end)
    return driver
Exemple #2
0
def login_domain(request, driver):
    """域管理员登录"""
    log.info("域管理员:%s登录" % domain_data["username"])
    login = loginaction.Login(driver)
    login.login(domain_data["username"], domain_data["password"])

    def end():
        log.info("测试用例执行完成,登出系统")
        driver.origin_driver.delete_all_cookies()

    request.addfinalizer(end)
    return driver
Exemple #3
0
def login_admin(request, driver):
    """系统管理员登录"""
    log.info("系统管理员登录")
    login = loginaction.Login(driver)
    login.login('系统管理员', '123456')

    def end():
        log.info("测试用例执行完成,登出系统")
        driver.origin_driver.delete_all_cookies()

    request.addfinalizer(end)
    return driver
Exemple #4
0
def driver(request):
    global driver
    '''只打开浏览器和关闭浏览器'''
    log.info("打开浏览器")
    driver = pyselenium.PySelenium(globalparam.browser)
    driver.max_window()  # 最大化

    def end():
        log.info("用例全部执行完毕,关闭浏览器")
        time.sleep(globalparam.small)
        driver.quit()

    request.addfinalizer(end)
    return driver
Exemple #5
0
 def end():
     log.info("测试用例执行完成,登出系统")
     driver.origin_driver.delete_all_cookies()
Exemple #6
0
 def end():
     log.info("用例全部执行完毕,关闭浏览器")
     time.sleep(globalparam.small)
     driver.quit()
Exemple #7
0
if __name__ == '__main__':

    log = log.Log()
    shell = shell.Shell()
    xml_report_path = globalparam.xml_report_path
    html_report_path = globalparam.html_report_path

    # 初始化allure环境配置文件environment.xml
    initializeEnv.Init_Env().init()
    # 定义测试集
    args = ['-s', '-q', '--alluredir', xml_report_path]
    pytest.main(args)
    cmd = 'allure generate %s -o %s --clean' % (xml_report_path,
                                                html_report_path)
    log.info("执行allure,生成测试报告")
    log.debug(cmd)
    try:
        log.info("执行allure")
        shell.invoke(cmd)
    except Exception:
        log.error('执行用例失败,请检查环境配置')
        raise
    # 解决历史趋势中无数据问题
    report_history_path = html_report_path + "\\history"
    result_history_path = xml_report_path + "\\history"
    copy_cmd = 'xcopy %s %s  /e /Y /I' % (report_history_path,
                                          result_history_path)
    try:
        log.info("复制历史数据")
        shell.invoke(copy_cmd)