Пример #1
0
 def addFailure(self, test, err):
     self.failure_count += 1
     self.status = 1
     TestResult.addFailure(self, test, err)
     _, _exc_str = self.failures[-1]
     output = self.complete_output()
     self.result.append((1, test, output, _exc_str))
     # if not getattr(test, "driver",""):
     #     pass
     # else:
     #     try:
     #         driver = getattr(test, "driver")
     #         test.imgs.append(driver.get_screenshot_as_base64())
     #     except Exception as e:
     #         pass
     try:
         driver = WDriver().get_driver()
         my_log = init_logger()
         my_log.info("****addFailure****")
         fail_image = "<img src=\"data:image/png;base64,{}\"/>".format(
             driver.get_screenshot_as_base64())
         log = [str(err), fail_image]
         self.test_result_list.append(
             self.gen_case_info(str(test), "addFailure", log))
     except Exception as e:
         print(e)
     if self.verbosity > 1:
         sys.stderr.write('F  ')
         sys.stderr.write(str(test))
         sys.stderr.write('\n')
     else:
         sys.stderr.write('F')
Пример #2
0
import sys
reload(sys)
sys.setdefaultencoding('utf8')
import time, os, unittest, subprocess, pytest, unittest, allure
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions
from config import *
from page.basepage import BasePage
from driver.wdriver import WDriver
from page.homepage import HomePage
from parameterized import parameterized
from libs.logger import init_logger
logger = init_logger()  # 初始化日志


@allure.feature("首页")
class TestHomePage(BasePage):
    def setUp(self):
        super(TestHomePage, self).setUp()
        logger.info("TestHomePage")
        self.home_page = HomePage()

    @allure.story("首页-搜索")
    @parameterized.expand([
        [u"绿皮书", "Two"],
        [u"流浪地球", "Four"],
        [u"阿丽塔", "Six"],
    ])
Пример #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os, re, time, subprocess, sys, jinja2, requests, json
from jinja2 import Environment, PackageLoader
from libs.logger import init_logger
logger = init_logger()

project_path = os.path.abspath(os.path.dirname(__file__))
report_folder = os.path.join(project_path, "report")
if not os.path.exists(report_folder):
    os.mkdir(report_folder)
    print("\033[0;32m{0}\033[0m".format("创建报告文件夹:".format(report_folder)))


class GenReport():
    def __init__(self, result_data):
        self.result_data = result_data

    def render_reprot(self, **params):
        '''
        jinja2渲染结果
        :return:
        '''
        db = None
        try:
            env = Environment(loader=PackageLoader('AutoReport', 'template'))
            template = env.get_template("template.html")
            html_content = template.render(result_data=self.result_data)
            current_now = time.strftime("%Y%m%d%H%M%S", time.localtime())
            report_path = os.path.join(report_folder,