def _run_maxim(run, cases, command, actions, widget_black): log = Log() log.set_logger(run.get_device()['model'], os.path.join(run.get_path(), 'client.log')) log.i('udid: %s', run.get_device()['udid']) # set cls.path, it must be call before operate on any page path = ReportPath() path.set_path(run.get_path()) # set cls.driver, it must be call before operate on any page base_page = BasePage() if 'ip' in run.get_device(): base_page.set_driver(run.get_device()['ip']) else: base_page.set_driver(run.get_device()['serial']) try: # run cases base_page.d.shell('logcat -c') # 清空logcat if cases: run.run_cases(cases) Maxim().run_monkey(monkey_shell=command, actions=actions, widget_black=widget_black) base_page.d.shell('logcat -d > /sdcard/logcat.log') time.sleep(1) base_page.d.pull('/sdcard/logcat.log', os.path.join(path.get_path(), 'logcat.log')) base_page.d.pull('/sdcard/monkeyerr.txt', os.path.join(path.get_path(), 'monkeyerr.txt')) base_page.d.pull('/sdcard/monkeyout.txt', os.path.join(path.get_path(), 'monkeyout.txt')) base_page.set_original_ime() base_page.identify() if 'ip' in run.get_device(): log.i('release device %s ' % run.get_device()['serial']) atxserver2().release_device(run.get_device()['serial']) except AssertionError as e: log.e('AssertionError, %s', e)
def _run_cases(run, cases, retry, save_last_try): log = Log() log.set_logger(run.get_device()['model'], run.get_path() + '/' + 'client.log') log.i('udid: %s' % run.get_device()['udid']) # set cls.path, it must be call before operate on any page path = ReportPath() path.set_path(run.get_path()) # set cls.driver, it must be call before operate on any page base_page = BasePage() if 'ip' in run.get_device(): base_page.set_driver(run.get_device()['ip']) else: base_page.set_driver(run.get_device()['serial']) try: # print(run.get_device()) # 运行前准备 base_page.unlock_device() base_page.set_fastinput_ime() # 设置fastime输入法 # base_page.d.shell('logcat -c') # 清空logcat # 开始执行测试 run.run(cases, retry, save_last_try) # 结束后操作 base_page.unwatch_device() base_page.set_original_ime() # 将logcat文件上传到报告 # base_page.d.shell('logcat -d > /sdcard/logcat.log') # time.sleep(2) # base_page.d.pull('/sdcard/logcat.log', os.path.join(path.get_path(), 'logcat.log')) if 'ip' in run.get_device(): log.i('release device %s ' % run.get_device()['serial']) atxserver2().release_device(run.get_device()['serial']) except AssertionError as e: log.e('AssertionError, %s' % e)