def re_crawl_mack_error_node(plan, app, device, page_before_run, node, activity): appController.start_activity(device, app.packageName, activity) page_now = get_page_info(plan, app, device) if nodeController.recover_node_shown(plan, app, device, page_now, page_before_run, node): device.save_make_error_node_screen(node) if node.crawlOperation == 'tap': appController.tap_node(device, node) elif node.crawlOperation == 'longclick': appController.long_click_node(device, node) elif node.crawlOperation == 'type': t = appController.get_random_text(8) appController.type_text(device, node, t) if not appController.app_is_running(device, app): Saver.save_error_logcat(plan, device) HtmlMaker.make_failed_result_html(plan, app) MailSender.send_failed_mail_necessary(plan, app, device, node) del plan, app, device, page_before_run, node, activity, page_now return False else: HtmlMaker.make_failed_result_html(plan, app) MailSender.send_failed_mail_un_necessary(plan, app, device) del plan, app, device, page_before_run, node, activity, page_now return True
def recover_node_shown(plan, app, device, page_now, page_before_run, node): t = 1 r = False while page_now is not None and page_now.nodesNum != 0 and node.nodeInfo not in page_now.nodesInfoList: if get_node_recover_way(device, page_now, page_before_run, node, []): r = True break Saver.save_crawler_log(device.logPath, "Step : no recover way , click back") device.save_screen_jump_out(page_now.package, page_now.currentActivity) appController.click_back(device) page_now = pageController.get_page_info(plan, app, device) t += 1 if t > 2: Saver.save_crawler_log(device.logPath, "can't find the node after back 3 times.") break if r: Saver.save_crawler_log(device.logPath, "Step : recover node shown") for n in node.recoverWay: device.save_screen(n, False) if n.crawlOperation == 'tap': appController.tap_node(device, n) elif n.crawlOperation == 'longclick': appController.long_click_node(device, n) elif n.crawlOperation == 'type': t = appController.get_random_text(8) appController.type_text(device, n, t) pageController.check_page_after_operation(plan, app, device, page_before_run, node) del n if t < 4: r = True del plan, app, device, page_now, page_before_run, node, t return r