def step_fail(message): """ 失败或者异常对当前页面截图 """ #mail(env.threadlocal.CASE_NAME, env.threadlocal.BROWSER.current_url, common.stamp_datetime_coherent()) screenshot_name = "Fail__%s__%s__%s.png" % (common.stamp_datetime_coherent( ), env.threadlocal.CASE_NAME, env.threadlocal.TESTING_BROWSER) write_log( os.path.join("testcase", "%s.log" % (env.threadlocal.CASE_NAME)), "------------ Fail [%s] -------------------\n" % common.stamp_datetime()) write_log( os.path.join("testcase", "%s.log" % (env.threadlocal.CASE_NAME)), "%s Fail: %s, Check ScreenShot [%s]\n" % (common.stamp_datetime(), message, screenshot_name)) write_log( os.path.join("testcase", "%s.log" % (env.threadlocal.CASE_NAME)), "------------ Fail [%s] --------------------------------------------\n" % common.stamp_datetime()) try: save_screen_shot(screenshot_name) except: step_normal(str(sys.exc_info())) env.HTMLREPORT_SCREENSHOT_NAME = screenshot_name env.threadlocal.CASE_PASS = False env.EXIT_STATUS = -1 raise AssertionError(message)
def step_warning(message): screenshot_name = "Warning__%s__%s__%s.png" % ( common.stamp_datetime_coherent(), env.threadlocal.CASE_NAME, env.threadlocal.TESTING_BROWSER) write_log( os.path.join("testcase", "%s.log" % (env.threadlocal.CASE_NAME)), "------------ Warning [%s] -------------------\n" % common.stamp_datetime()) write_log( os.path.join("testcase", "%s.log" % (env.threadlocal.CASE_NAME)), "%s Warning: %s, Check ScreenShot [%s]\n" % (common.stamp_datetime(), message, screenshot_name)) write_log( os.path.join("testcase", "%s.log" % (env.threadlocal.CASE_NAME)), "------------ Warning [%s] --------------------------------------------\n" % common.stamp_datetime()) try: save_screen_shot(screenshot_name) except: step_normal(str(sys.exc_info())) env.threadlocal.CASE_WARNINGS = env.threadlocal.CASE_WARNINGS + 1
def step_fail(message): screenshot_name = "%s__%s__Fail__%s.png" % (env.CASE_NAME, env.platformName, common.stamp_datetime_coherent()) with open(u"%s\\Result\\testcase\\%s__%s.log" % (env.PROJECT_PATH, env.CASE_NAME, common.stamp_date()), "a") as f: f.write("------------ Fail [%s] -------------------\n" % common.stamp_datetime()) f.write("%s Fail: %s, Check ScreenShot [%s]\n" % (common.stamp_datetime(), message, screenshot_name)) f.write("------------ Fail [%s] --------------------------------------------\n" % common.stamp_datetime()) common.mkdirs("%s\\Result\\screenshots\\" % env.PROJECT_PATH) env.driver.save_screenshot(u"%s\\Result\\screenshots\\%s" % (env.PROJECT_PATH, screenshot_name)) env.CASE_PASS = False raise AssertionError(message)
def handle_error(): if env.CASE_PASS == False: return if sys.exc_info()[0] != None: step_normal(common.exception_error()) screenshot_name = "%s__%s__Error_%s.png" % (env.CASE_NAME, env.platformName, common.stamp_datetime_coherent()) common.mkdirs("%s\\Result\\screenshots\\" % env.PROJECT_PATH) env.driver.save_screenshot(u"%s\\Result\\screenshots\\%s" % (env.PROJECT_PATH, screenshot_name)) step_normal("Please check screen short [%s]" % screenshot_name) env.CASE_PASS = False
def step_warning(message): screenshot_name = "Warning__%s__%s__%s.png" % (common.stamp_datetime_coherent(), env.threadlocal.CASE_NAME, env.threadlocal.TESTING_BROWSER) write_log(os.path.join("testcase", "%s.log" % (env.threadlocal.CASE_NAME)), "------------ Warning [%s] -------------------\n"%common.stamp_datetime()) write_log(os.path.join("testcase", "%s.log" % (env.threadlocal.CASE_NAME)), "%s Warning: %s, Check ScreenShot [%s]\n" %(common.stamp_datetime(), message, screenshot_name)) write_log(os.path.join("testcase", "%s.log" % (env.threadlocal.CASE_NAME)), "------------ Warning [%s] --------------------------------------------\n"%common.stamp_datetime()) try: save_screen_shot(screenshot_name) except: step_normal(str(sys.exc_info())) env.threadlocal.CASE_WARNINGS = env.threadlocal.CASE_WARNINGS + 1
def handle_error(): if env.threadlocal.CASE_PASS == False: return if sys.exc_info()[0] != None: step_normal(common.exception_error()) screenshot_name = "Fail__%s__%s__%s.png" % (common.stamp_datetime_coherent(), env.threadlocal.CASE_NAME, env.threadlocal.TESTING_BROWSER) try: save_screen_shot(screenshot_name) except: step_warning(str(sys.exc_info())) step_normal("Current step screen short [%s]" % (screenshot_name)) env.HTMLREPORT_SCREENSHOT_NAME = screenshot_name env.threadlocal.CASE_PASS = False env.EXIT_STATUS = -1
def step_fail(message): screenshot_name = "Fail__%s__%s__%s.png" % (common.stamp_datetime_coherent(), env.threadlocal.CASE_NAME, env.threadlocal.TESTING_BROWSER) write_log(os.path.join("testcase", "%s.log" % (env.threadlocal.CASE_NAME)), "------------ Fail [%s] -------------------\n"%common.stamp_datetime()) write_log(os.path.join("testcase", "%s.log" % (env.threadlocal.CASE_NAME)), "%s Fail: %s, Check ScreenShot [%s]\n" %(common.stamp_datetime(), message, screenshot_name)) write_log(os.path.join("testcase", "%s.log" % (env.threadlocal.CASE_NAME)), "------------ Fail [%s] --------------------------------------------\n"%common.stamp_datetime()) try: save_screen_shot(screenshot_name) except: step_normal(str(sys.exc_info())) env.HTMLREPORT_SCREENSHOT_NAME = screenshot_name env.threadlocal.CASE_PASS = False env.EXIT_STATUS = -1 raise AssertionError(message)
def step_fail(message): screenshot_name = "Fail__%s__%s__%s.png" % (common.stamp_datetime_coherent(), env.threadlocal.CASE_NAME, env.threadlocal.TESTING_BROWSER) write_log(os.path.join("testcase", "%s.txt" % (env.threadlocal.CASE_NAME)), "------------ Fail [%s] -------------------\n"%common.stamp_datetime()) print("testcase : %s ------------ Fail [%s] -------------------\n" % (env.threadlocal.CASE_NAME, common.stamp_datetime())) write_log(os.path.join("testcase", "%s.txt" % (env.threadlocal.CASE_NAME)), "%s Fail: %s, Check ScreenShot [%s]\n" %(common.stamp_datetime(), message, screenshot_name)) print("testcase : %s -- %s Fail: %s, Check ScreenShot [%s]" % (env.threadlocal.CASE_NAME, common.stamp_datetime(), message, screenshot_name)) write_log(os.path.join("testcase", "%s.txt" % (env.threadlocal.CASE_NAME)), "------------ Fail [%s] --------------------------------------------\n"%common.stamp_datetime()) print("testcase : %s------------ Fail [%s] --------------------------------------------\n" % (env.threadlocal.CASE_NAME, common.stamp_datetime())) try: save_screen_shot(screenshot_name) except: step_normal(str(sys.exc_info())) env.HTMLREPORT_SCREENSHOT_NAME = screenshot_name env.threadlocal.CASE_PASS = False env.EXIT_STATUS = -1