Пример #1
0
def env_init():
	auto_setup(__file__, logdir=apkManage_logdir, devices=["Android:///"])
	print("完成环境初始化")

	yield
	simple_report(filepath=os.path.realpath(__file__), logpath=apkManage_logdir, logfile=logfile, output=apkManage_output)
	print("输出包管理报告")
Пример #2
0
 def adb_report(self, path):
     """
     自动生成报告
     :param path:
     :return:
     """
     simple_report(__file__, logpath=f'{path}', logfile=f'{path}/log.txt', output=f'{path}/log.html')
     return
Пример #3
0
 def report(self):
     '''报告生成'''
     simple_report(
         __file__,
         logpath=
         r'C:\Users\majiexiong\PycharmProjects\airtest_demo\center\log',
         output=
         r'C:\Users\majiexiong\PycharmProjects\airtest_demo\center\log\log.html'
     )
Пример #4
0
def common_utils_report(path):
    """
    生成报告
    """
    simple_report(__file__,
                  logpath=f'{path}',
                  logfile=f'{log_run}/log.txt',
                  output=f'{log_run}/log.html')
    return
Пример #5
0
def auto_generate_report(auto_report_Flag=False):
    '''自动生成报告'''
    if auto_generate_report==True:
        print("auto_generate_report--------------start")
        # generate html report
        from airtest.report.report import simple_report
        #生成报告目录
        output_file = targetLodDir + '/log.html'
        #生成报告的方法
        simple_report(root_dir, logpath=targetLodDir, output=output_file)
        print("auto_generate_report--------------end")
Пример #6
0
 def testSkillSelect1(self):
     auto_setup(__file__, logdir=True)
     touch(Template(r"tpl1578657509331.png", target_pos=6, record_pos=(0.165, 0.059), resolution=(2310, 1080)))
     assert_exists(Template(r"tpl1578657165257.png", record_pos=(-0.382, 0.052), resolution=(2310, 1080)), "На месте")
     touch(Template(r"tpl1578668006338.png", record_pos=(-0.385, 0.047), resolution=(2310, 1080)))
     assert_exists(Template(r"tpl1578668271653.png", record_pos=(-0.29, 0.044), resolution=(2310, 1080)), "первый скилл открыт")
     assert_exists(Template(r"tpl1578668298982.png", record_pos=(-0.384, 0.046), resolution=(2310, 1080)), "Ветка стрелка выбрана")       
     touch(Template(r"tpl1578668055794.png", record_pos=(-0.385, 0.136), resolution=(2310, 1080)))
     assert_exists(Template(r"tpl1578668160579.png", record_pos=(-0.29, 0.045), resolution=(2310, 1080)), "Первый скил открыт")
     assert_exists(Template(r"tpl1578668184565.png", record_pos=(-0.384, 0.133), resolution=(2310, 1080)), "Ветка магии выбрана")
     simple_report(__file__, logpath=True, output='reportSkillSelect1.html')
Пример #7
0
 def testProfile(self, x):
     auto_setup(__file__, logdir=True)
     wait(Template(r"waitAllow.png", record_pos=(-0.008, -0.068), resolution=(2310, 1080)))
     touch(Template(r"allow.png", record_pos=(0.094, 0.127), resolution=(2310, 1080)))
     touch(Template(r"tpl1578653206245.png", record_pos=(-0.398, -0.176), resolution=(2310, 1080)))
     wait(Template(r"tpl1578664637506.png", record_pos=(-0.054, -0.089), resolution=(2310, 1080)))
     snapshot(filename="PofileMenu.png", msg="Please fill in the test point.")        
     assert_exists(Template(r"tpl1578653371049.png", record_pos=(-0.09, 0.097), resolution=(2310, 1080)), "Смена имени на месте")
     assert_exists(Template(r"tpl1578653392440.png", record_pos=(-0.365, 0.187), resolution=(2310, 1080)), "Поддержка на месте")
     assert_exists(Template(r"tpl1578653426063.png", record_pos=(-0.413, -0.192), resolution=(2310, 1080)), "Назад на месте")
     assert_exists(Template(r"tpl1578653574481.png", record_pos=(0.154, 0.001), resolution=(2310, 1080)), "Настройки звука на месте")
     simple_report(__file__, logpath=True, output='reportProfile.html')
Пример #8
0
 def partReport(self, htmlname, k, __title__):
     """分步报告"""
     mylog.info(
         "-------------------------【{0}】执行完毕-----------------".format(
             __title__))
     print("-----执行完毕-----")
     outputpath = os.path.join(path_REPORT_DIR, htmlname)
     self.writelogs()
     simple_report(__file__, logpath=path_LOG_DIR, output=outputpath)
     self.Case_info[k]["repeattime"] = self.Case_info[k]["repeattime"] - 1
     auto_setup(logdir=path_LOG_DIR)
     mylog.info("完成html测试报告,等待生产录制文件需要一定时间")
Пример #9
0
 def togetherReport(self):
     """生成最后的合成日志"""
     htmlname = self.Case_info["casename"] + ".html"
     htmlpath = os.path.join(path_REPORT_DIR, htmlname)
     logspath = os.path.join(path_LOG_DIR, "logs.txt")
     logpath = os.path.join(path_LOG_DIR, "log.txt")
     try:
         with open(logspath, 'r') as f1:
             with open(logpath, 'w') as f2:
                 f2.write(f1.read())
         simple_report(__file__,
                       logpath=path_LOG_DIR,
                       output=htmlpath,
                       MY_DEFAULT_LOG_FILE="logs.txt")
     except:
         print("未发现logs日志")
Пример #10
0
def ini():

    # file_name = os.environ.get('PYTEST_CURRENT_TEST').split(':')[0].split('/')[1].split('.')[0]
    # logging.info("用例文件名称:%s" % file_name)
    # global air_log
    # air_log = os.path.join(air_log_path, file_name + "_" + now)
    # os.makedirs(air_log)
    # 初始化应用
    start_app("com.fdage.eight")
    sleep(10)

    yield
    # 生成报告
    now = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime())
    simple_report(__file__,
                  logpath=air_log_path,
                  output=air_report_path + "\\air_report_" + str(now) +
                  ".html")
    stop_app("com.fdage.eight")
Пример #11
0
 def _wrap(*args, **kwargs):
     print("调用到了")
     print("这是 " + __file__)
     curdir_time = str(int(time.time()))
     logdir = log_path + '/' + curdir_time + '/' + func.__name__
     print("日志路径:" + logdir)
     os.makedirs(logdir)
     auto_setup(__file__, logdir=logdir, project_root=True)
     print(func)
     func(*args)
     logfile = logdir + f'/{func.__name__}.html'
     simple_report(__file__, logpath=logdir, output=logfile)
     time.sleep(2)
     print("这是啥: " + pkdir)
     with open(logfile, 'r+', encoding='utf-8') as f:
         context = f.read()
         temp = context.replace(os.path.dirname(rootpath), '')
         print("看看:", os.path.dirname(rootpath))
     # print(temp)
     allure.attach(temp, 'report.html', attachment_type=allure.attachment_type.HTML)
Пример #12
0
def env_init():
    auto_setup(__file__, logdir=docs_logdir, devices=["Android:///"])
    #auto_setup(__file__, logdir=docs_logdir, devices=["Android://127.0.0.1:5037/127.0.0.1:62001"])
    print("完成环境初始化")
    clear_app(apk)

    start_app(apk)
    sleep(2)
    
    authApp()

    login('kentest50','12345678','p1','kentest50')
    
    #selectMode("组织架构聚合")
    selectOrg_0(org_name='公司1项目贰')
    selectApp("图纸文档")    

    yield
    simple_report(filepath=os.path.realpath(__file__), logpath=docs_logdir, logfile=logfile, output=docs_output)
    print("输出文档模块报告")
Пример #13
0
 def test_app(self):
     self.poco(name='android.view.View').wait_for_appearance()
     self.poco(name='android.view.View').click()
     self.poco(text="搜索或输入网址").click()
     text("测试", enter=False)
     screen = aircv.crop_image(self.screen, (27, 98, 902, 197))
     self.poco.swipe([0.5, 0.5], [0.1, 0.1])
     # try_log_screen(screen) #报错局部截图到log文件中
     # 生成测试报告
     dev = device()
     dev.swipe_along([[959, 418], [1157, 564], [1044, 824], [751, 638],
                      [945, 415]])
     '''长距离多点滑动'''
     dev.pinch(in_or_out='in', center=None, percent=0.5)
     '''双指向内捏合动作,向外的话in改成out'''
     from airtest.report.report import simple_report
     simple_report(__file__,
                   logpath=applog_path,
                   output=(os.path.join(report_path, '%s.html') %
                           (time.strftime('%Y-%m-%d-%H-%M-%S'))
                           ))  #用airtest的方法生成报告,徐填写log.txt的位置,以及输出报告的位置
Пример #14
0
 def run(self, times=None):
     if times:
         self.run_times = times
     if not self.run_times:
         self.run_times = int(input("input times\n"))
     self.now_times = 0
     try:
         for i in range(0, self.run_times):
             self.step()
             self.now_times = i + 1
             print(
                 str.format(
                     "第%d次,剩余%d次" %
                     (self.now_times, self.run_times - self.now_times)))
             print(
                 str.format(
                     "第%d次,剩余%d次" %
                     (self.now_times, self.run_times - self.now_times)))
     except Exception as e:
         f = open(self.TRACE_PATH, 'w', encoding="UTF-8")
         traceback.print_exc(None, f, True)
         localtime = time.asctime(time.localtime(time.time()))
         f.write(localtime.__str__() + "\n")
         f.flush()
         f.close()
         if self.context.debug:
             os.system("start " + self.TRACE_PATH)
         # print(traceback.format_exc())
         traceback.print_exc()
     except KeyboardInterrupt as interrupt:
         if self.context.debug:
             os.system("start " + self.TRACE_PATH)
     finally:
         print(
             str.format("第%d次未完整完成,剩余%d次" %
                        (self.now_times, self.run_times - self.now_times)))
         simple_report(self.filePath(), logpath=True)
Пример #15
0
            #測試點,驗證是否轉賬成功
            assert_exists(
                Template(r"tpl1575891204100.png",
                         record_pos=(0.005, -0.299),
                         resolution=(1080, 1920)), "轉賬成功")
            print("轉賬流程測試成功")

            #返回首頁
            poco(text="完成").click()
            print("----------------同行轉賬流程結束----------------------")

            # 退出app
            ba.stop_app()

        except Exception as e:
            print("-------------异常情况-------------")
            ba.log_error("同行转账流程错误 \n %s" % (e))
            print(e)
            # 退出app
            ba.stop_app()


if __name__ == "__main__":
    # 执行
    t = Transfer()
    t.transfer()
    # 生成报告
    simple_report(__file__,
                  logpath='./case/p_transfer/log',
                  output='./report/transfer.HTML')
Пример #16
0
def creat_report(logpath, output):
    simple_report(__file__, logpath=logpath, output=output)
Пример #17
0
start_app(PKG)
sleep(2)

# next 3 sentences are generated with AirtestIDE
touch(
    Template(r"tpl1499240443959.png",
             record_pos=(0.22, -0.165),
             resolution=(2560, 1536)))
assert_exists(
    Template(r"tpl1499240472304.png",
             record_pos=(0.0, -0.094),
             resolution=(2560, 1536)), "请下注")
p = wait(
    Template(r"tpl1499240490986.png",
             record_pos=(-0.443, -0.273),
             resolution=(2560, 1536)))

# touch a position
touch(p)
sleep(2)

# stop the app
stop_app(PKG)
sleep(2)
snapshot(msg="app stopped")

print("test finished")

# generate html report
simple_report("log", __file__)
Пример #18
0
 def tearDownClass(cls):
     simple_report(filepath=os.path.realpath(__file__), logpath=safety_logdir, logfile=logfile, output=safety_output)
Пример #19
0
def tests_runner(main_script, file_config):
    # читаем конфиг из config-файла
    package, data_config = read_data_from_config(file_config)
    gl_report = []

    # на сколько я понял это каждый раз открывает новое соединение
    
    '''
    # подключаемся к девайсу
    if run_on_emulator: # для эмулятора
        init_device(platform='Android', cap_method='JAVACAP', ori_method='ADBORI')
    else: # для девайса
        init_device(platform='Android')
        log('Init Device')
    '''
    init_device(platform='Android')
    dev = device()
    poco = UnityPoco()

    # вроде всё готово для тестов:
    t0 = time.time();
    out('Cases::tests_runner()... started')
    
    # выставляем значения по умолчанию потому что предыдущего теста не было
    last_test_stop_app = False
    need_wake = True
    # for line in data_csv:
    for line in data_config:
        # из config-файла
        test_id, f_wake, f_stop_before, f_clear_app, f_push_saves, \
        f_start_app, f_stop_after = parse_line_from_config(line)
    
        if need_wake:
            f_wake = True
            need_wake = False
    
        if last_test_stop_app:
            f_stop_before = True
            f_start_app = True
            last_test_stop_app = False
    
        # создаём логирование
        log_path = 'report(' + test_id + ')'
        set_logdir(log_path)
    
        #  пробуждаем устройство
        if f_wake: 
            wake()
            
        #  останавливаем приложение
        if f_stop_before: 
            stop_app(package);
            time.sleep(1)

        #  отчистить даные приложения            
        if f_clear_app: 
            clear_app(package)
            
        #  подсовываем сэйвы
        if f_push_saves != '': 
            push_my_saves(f_push_saves, package)
            
        #  стартуем приложение
        if f_start_app: 
            start_app(package)
            time.sleep(10)
            poco = UnityPoco()

        # запускаем тест
        tt0 = time.time();
        result, runned = test_runner(dev, poco, test_id)
        dtt = time.time() - tt0
        print('test: ' + test_id + '; ' + \
              'runned: ' + str(runned) + '; ' + \
              'result: ' + str(result) + '; ' + \
              'time(sec): ' + str(int(dtt)))
        print('-----------------------')
        if not result:
            last_test_stop_app = True
            f_stop_after = True
        gl_report.append([test_id, runned, result, dtt])
        
        #  останавливаем приложение
        if f_stop_after: 
            last_test_stop_app = True
            stop_app(package)
            
        # далее обязательная секция чтобы сгенерить отчёт
        report_path = get_log_path(main_script, log_path)
        print(report_path)
        simple_report(main_script, report_path, output='report(' + test_id + ').html')

    t1 = time.time()
    out('Cases::tests_runner()... complete (' + str(t1 - t0) + ' sec)')

    # заключительный репорт gl_report
    log_path = 'report'
    set_logdir(log_path)

    for gl_data in gl_report:
        txt = gl_data[0] + ' '
        prop = ''
        if not gl_data[1]:
            prop += 'тест не найден'
        else:
            txt += '(' + str(int(gl_data[3])) + ' sec)'
            if not gl_data[2]:
                prop += 'тест не пройден'
        out(txt, prop)

    # далее обязательная секция чтобы сгенерить отчёт
    report_path = get_log_path(main_script, log_path)
    print(report_path)
    simple_report(main_script, report_path, output='global_report.html')
Пример #20
0
# install and start the app
wake()
home()

if PKG not in device().list_app():
    install(APK)

stop_app(PKG)
start_app(PKG)
sleep(2)

# next 3 sentences are generated with AirtestIDE
touch(Template(r"tpl1499240443959.png", record_pos=(0.22, -0.165), resolution=(2560, 1536)))
assert_exists(Template(r"tpl1499240472304.png", record_pos=(0.0, -0.094), resolution=(2560, 1536)), "请下注")
p = wait(Template(r"tpl1499240490986.png", record_pos=(-0.443, -0.273), resolution=(2560, 1536)))

# touch a position
touch(p)
sleep(2)

# stop the app
stop_app(PKG)
sleep(2)
snapshot(msg="app stopped")

print("test finished")

# generate html report
from airtest.report.report import simple_report
simple_report(__file__)
Пример #21
0
def log_report():
    from airtest.report.report import simple_report
    simple_report(__file__,
                  logpath="D:/test/log",
                  output="D:/test/log/log.html")
Пример #22
0
                                    "android.view.ViewGroup").child(
                                        "android.view.ViewGroup")[0].click()

            #查看是否有总资产
            assert_exists(
                Template(r"tpl1575966345628.png",
                         record_pos=(-0.045, -0.744),
                         resolution=(1080, 2244)), "總資產(MOP)")
            print("登錄成功")
            print("----------------测试登錄流程結束----------------------")

            #退出app
            ba.stop_app()

        except Exception as e:
            print("-------------异常情况-------------")
            ba.log_error("登陆流程错误: \n %s" % (e))
            print(e)
            # 退出app
            ba.stop_app()


if __name__ == "__main__":
    #执行
    l = login()
    l.login()
    # 生成报告
    simple_report(__file__,
                  logpath='./case/login/log',
                  output='./report/login.HTML')
Пример #23
0
 def test_simple_report(self):
     simple_report(OWL)
     self.assertTrue(os.path.exists(self.OUTPUT_HTML))
Пример #24
0
def link_report():
    simple_report(__file__,
                  logpath=f"{log_run}",
                  logfile=f'{log_run}/log.txt',
                  output=f"{log_run}/log.html")
Пример #25
0
if PKG not in device().list_app():
    install(APK)

stop_app(PKG)
start_app(PKG)
sleep(2)

touch(
    Template(r"tpl1499240443959.png",
             record_pos=(0.22, -0.165),
             resolution=(2560, 1536)))
assert_exists(
    Template(r"tpl1499240472304.png",
             record_pos=(0.0, -0.094),
             resolution=(2560, 1536)), "请下注")
p = wait(
    Template(r"tpl1499240490986.png",
             record_pos=(-0.443, -0.273),
             resolution=(2560, 1536)))

touch(p)
sleep(2)
stop_app(PKG)
sleep(2)
snapshot(msg="app stopped")

print("test finished")

# generate html report
simple_report("logs")
Пример #26
0
    '''首页-等待加载'''
    #start_app("com.yiwang.fangkuaiyi")
    print('等待首页加载:超时时间=10秒')
    wait(bottom_home_active, timeout=10)
    print('首页已加载')
    return exists(bottom_home_active), bottom_home_active


def home_go_to_1yaodai():
    '''首页-跳转1药贷'''
    touch(menu_1yaodai)
    sleep(1)
    return exists(menu_1yaodai)


def home_go_mine():
    '''首页-跳转 我的'''
    touch(bottom_mine_inactive)
    sleep(1)
    return exists(bottom_mine_active)


if __name__ == '__main__':
    auto_setup(__file__, devices=['Android:///'], logdir=True)
    #connect_device('Android:///') #android:/// or Android://127.0.0.1:5037/YOUR_UUID
    # YOUR CODES .....
    print('main')
    home_init()
    from airtest.report.report import simple_report
    simple_report(__file__, logpath=True)