From 994338776b6bad68c11b1fd8c81aee6c94d8ab02 Mon Sep 17 00:00:00 2001 From: tsbxmw <1050636648@qq.com> Date: Fri, 15 Feb 2019 11:18:29 +0800 Subject: [PATCH 1/6] bug fix:wrong png dir when using . path --- haf/apphelper.py | 2 +- haf/config.py | 2 +- haf/runner.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/haf/apphelper.py b/haf/apphelper.py index 0ad366c..eea1774 100644 --- a/haf/apphelper.py +++ b/haf/apphelper.py @@ -155,7 +155,7 @@ def deserialize(self): def save_screen_shot(driver, path, name): try: - path = f"{path}/png" + path = f"{path}" if not os.path.exists(path): os.mkdir(path) path_full = f"{path}/{name}.png" diff --git a/haf/config.py b/haf/config.py index 5207bcd..7043221 100644 --- a/haf/config.py +++ b/haf/config.py @@ -80,7 +80,7 @@ MAIN_VERSION = 2 SUB_VERSION = 3 -FIX_VERSION = 3 +FIX_VERSION = 4 VERSION_TYPE = "dev" PLATFORM_VERSION = f"{VERSION_TYPE}-{MAIN_VERSION}.{SUB_VERSION}.{FIX_VERSION}" diff --git a/haf/runner.py b/haf/runner.py index cd4d670..dc6c58e 100644 --- a/haf/runner.py +++ b/haf/runner.py @@ -367,12 +367,12 @@ def run(self, case: AppCase): from appium import webdriver driver = webdriver.Remote(APP_DRIVER_PATH, case.desired_caps.deserialize()) logger.info(f"{case.log_key} : wait app start ...") - time.sleep(10) + time.sleep(20) logger.info(f"{case.log_key} : driver is {driver}") page = BasePage(driver) for key in range(1, len(case.stages.keys())+1): logger.info(f"{case.log_key} : {key} == {case.stages.get(key).deserialize()}") - png_dir = f"{self.log_dir}" + png_dir = "./png" png_name = f"{case.bench_name}.{case.ids.id}.{case.ids.subid}.{case.ids.name}.{key}" png_before = save_screen_shot(driver, png_dir, f"{png_name}-before") self.run_stage(case, page, case.stages.get(key), result) From 718412200a2bf1a25f3cbef253206ea47637a7aa Mon Sep 17 00:00:00 2001 From: tsbxmw <1050636648@qq.com> Date: Fri, 15 Feb 2019 11:28:33 +0800 Subject: [PATCH 2/6] bug fix : wrong png dir in html report --- haf/apphelper.py | 7 +++++-- haf/case.py | 1 + haf/config.py | 2 +- haf/runner.py | 8 ++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/haf/apphelper.py b/haf/apphelper.py index eea1774..1f2b285 100644 --- a/haf/apphelper.py +++ b/haf/apphelper.py @@ -79,6 +79,7 @@ def __init__(self): self.operation = "" self.path = "" self.show_try = True + self.time_sleep = 5 self.info = {} def constructor(self, input: dict={}): @@ -88,6 +89,7 @@ def constructor(self, input: dict={}): self.path = input.get("path") self.show_try = input.get("try") self.info = input.get("info") + self.time_sleep = input.get("sleep") def deserialize(self): return { @@ -96,7 +98,8 @@ def deserialize(self): "operation": self.operation, "path": self.path, "show_try": self.show_try, - "info": self.info + "info": self.info, + "time_sleep": self.time_sleep } @@ -155,7 +158,7 @@ def deserialize(self): def save_screen_shot(driver, path, name): try: - path = f"{path}" + path = f"{path}/png" if not os.path.exists(path): os.mkdir(path) path_full = f"{path}/{name}.png" diff --git a/haf/case.py b/haf/case.py index 7b8238b..3dd1857 100644 --- a/haf/case.py +++ b/haf/case.py @@ -178,6 +178,7 @@ def _init_all(self): self.error = None self.sqlinfo = SqlInfo() self.time_sleep = 5 + self.wait_time = 20 self.pngs = {} def constructor(self, *args, **kwargs): diff --git a/haf/config.py b/haf/config.py index 7043221..a0217d5 100644 --- a/haf/config.py +++ b/haf/config.py @@ -80,7 +80,7 @@ MAIN_VERSION = 2 SUB_VERSION = 3 -FIX_VERSION = 4 +FIX_VERSION = 5 VERSION_TYPE = "dev" PLATFORM_VERSION = f"{VERSION_TYPE}-{MAIN_VERSION}.{SUB_VERSION}.{FIX_VERSION}" diff --git a/haf/runner.py b/haf/runner.py index dc6c58e..06f5074 100644 --- a/haf/runner.py +++ b/haf/runner.py @@ -367,17 +367,17 @@ def run(self, case: AppCase): from appium import webdriver driver = webdriver.Remote(APP_DRIVER_PATH, case.desired_caps.deserialize()) logger.info(f"{case.log_key} : wait app start ...") - time.sleep(20) + time.sleep(case.time_sleep) logger.info(f"{case.log_key} : driver is {driver}") page = BasePage(driver) for key in range(1, len(case.stages.keys())+1): logger.info(f"{case.log_key} : {key} == {case.stages.get(key).deserialize()}") - png_dir = "./png" + png_dir = f"{self.log_dir}}" png_name = f"{case.bench_name}.{case.ids.id}.{case.ids.subid}.{case.ids.name}.{key}" png_before = save_screen_shot(driver, png_dir, f"{png_name}-before") self.run_stage(case, page, case.stages.get(key), result) png_after = save_screen_shot(driver, png_dir, f"{png_name}-after") - case.pngs[key] = {"before": png_before, "after": png_after} + case.pngs[key] = {"before": f"./png/{png_before}.png", "after": f"./png/{png_after}.png"} result.case = case result.result = RESULT_PASS except Exception as e: @@ -398,7 +398,7 @@ def run_stage(self, case, page, stage: Stage=Stage(), result: AppResult=AppResul page.send_keys(paths, stage.info.get("keys")) elif operation == OPERATION_APP_SWIPE: page.swipe(stage.info.get("direction")) - time.sleep(case.time_sleep) + time.sleep(stage.time_sleep) except Exception as e: logger.error(e) result.run_error = e From 8680adadc8be11209a3f2933c3b85dd1bb4bb5da Mon Sep 17 00:00:00 2001 From: tsbxmw <1050636648@qq.com> Date: Fri, 15 Feb 2019 11:30:45 +0800 Subject: [PATCH 3/6] bug fix: wrong fstring , remove } --- haf/config.py | 2 +- haf/runner.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/haf/config.py b/haf/config.py index a0217d5..de7dab7 100644 --- a/haf/config.py +++ b/haf/config.py @@ -80,7 +80,7 @@ MAIN_VERSION = 2 SUB_VERSION = 3 -FIX_VERSION = 5 +FIX_VERSION = 6 VERSION_TYPE = "dev" PLATFORM_VERSION = f"{VERSION_TYPE}-{MAIN_VERSION}.{SUB_VERSION}.{FIX_VERSION}" diff --git a/haf/runner.py b/haf/runner.py index 06f5074..1256144 100644 --- a/haf/runner.py +++ b/haf/runner.py @@ -372,7 +372,7 @@ def run(self, case: AppCase): page = BasePage(driver) for key in range(1, len(case.stages.keys())+1): logger.info(f"{case.log_key} : {key} == {case.stages.get(key).deserialize()}") - png_dir = f"{self.log_dir}}" + png_dir = f"{self.log_dir}" png_name = f"{case.bench_name}.{case.ids.id}.{case.ids.subid}.{case.ids.name}.{key}" png_before = save_screen_shot(driver, png_dir, f"{png_name}-before") self.run_stage(case, page, case.stages.get(key), result) From 1129332bd386ba4e922016c025cc2f78af872c1e Mon Sep 17 00:00:00 2001 From: tsbxmw <1050636648@qq.com> Date: Fri, 15 Feb 2019 11:33:42 +0800 Subject: [PATCH 4/6] add appcase.time_sleep to wait app start --- haf/case.py | 3 +-- haf/config.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/haf/case.py b/haf/case.py index 3dd1857..d42b9a0 100644 --- a/haf/case.py +++ b/haf/case.py @@ -178,7 +178,6 @@ def _init_all(self): self.error = None self.sqlinfo = SqlInfo() self.time_sleep = 5 - self.wait_time = 20 self.pngs = {} def constructor(self, *args, **kwargs): @@ -193,7 +192,7 @@ def constructor(self, *args, **kwargs): else: args_init = kwargs self.ids.constructor(args_init) - self.time_sleep = args_init.get("sleep") or 5 + self.time_sleep = args_init.get("wait_time") or 5 self.run = CASE_RUN if args_init.get("run") is True else CASE_SKIP self.dependent = [x for x in str(args_init.get("dependent")).split(";") if args_init.get("dependent") is not None] self.desired_caps.constructor(args_init.get("desired_caps")) diff --git a/haf/config.py b/haf/config.py index de7dab7..b7af0da 100644 --- a/haf/config.py +++ b/haf/config.py @@ -80,7 +80,7 @@ MAIN_VERSION = 2 SUB_VERSION = 3 -FIX_VERSION = 6 +FIX_VERSION = 7 VERSION_TYPE = "dev" PLATFORM_VERSION = f"{VERSION_TYPE}-{MAIN_VERSION}.{SUB_VERSION}.{FIX_VERSION}" From 377e5250d611963cbdedc5d2f0e69dfb4a5b33e7 Mon Sep 17 00:00:00 2001 From: tsbxmw <1050636648@qq.com> Date: Fri, 15 Feb 2019 11:46:52 +0800 Subject: [PATCH 5/6] update report base_app, change png size to 150x300 --- haf/config.py | 2 +- haf/ext/resource/report/base_app.html | 20 ++++++++++---------- haf/ext/resource/report/base_online_app.html | 20 ++++++++++---------- haf/runner.py | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/haf/config.py b/haf/config.py index b7af0da..6c62088 100644 --- a/haf/config.py +++ b/haf/config.py @@ -80,7 +80,7 @@ MAIN_VERSION = 2 SUB_VERSION = 3 -FIX_VERSION = 7 +FIX_VERSION = 8 VERSION_TYPE = "dev" PLATFORM_VERSION = f"{VERSION_TYPE}-{MAIN_VERSION}.{SUB_VERSION}.{FIX_VERSION}" diff --git a/haf/ext/resource/report/base_app.html b/haf/ext/resource/report/base_app.html index 0efeeb0..9716b58 100644 --- a/haf/ext/resource/report/base_app.html +++ b/haf/ext/resource/report/base_app.html @@ -222,8 +222,8 @@ {% for stage in case.case.stages.values()%}