From 3a81cd3c619737aa149cc589bdab5b90ae82be85 Mon Sep 17 00:00:00 2001 From: Muntasib-creator Date: Mon, 8 Feb 2021 20:40:02 +0600 Subject: [PATCH 1/2] local_run implemented --- Framework/MainDriverApi.py | 7 +- Projects/Local_run.json | 185 ------------------------------------- node_cli.py | 11 +-- 3 files changed, 2 insertions(+), 201 deletions(-) delete mode 100644 Projects/Local_run.json diff --git a/Framework/MainDriverApi.py b/Framework/MainDriverApi.py index b222008c5..fcb778079 100644 --- a/Framework/MainDriverApi.py +++ b/Framework/MainDriverApi.py @@ -1771,8 +1771,7 @@ def main(device_dict, user_info_object): cnt += 1 with open(json_path, "r") as f: all_run_id_info = json.loads(f.read()) - with open(Path.cwd().parent / "Projects" / "Local_run.json", "w") as f: - f.write(json.dumps(all_run_id_info)) + if len(all_run_id_info) == 0: CommonUtil.ExecLog("", "No Test Run Schedule found for the current user : %s" % Userid, 2) return False @@ -1789,7 +1788,6 @@ def main(device_dict, user_info_object): path = ConfigModule.get_config_value("sectionOne", "temp_run_file_path", temp_ini_file) / Path(run_id.replace(":", "-")) FL.CreateFolder(path) - # Start websocket server if we're in debug mode. if run_id.lower().startswith("debug"): print("[LIVE LOG] Connecting to Live Log service") @@ -1984,9 +1982,6 @@ def kill(process): upload_json_report(Userid, temp_ini_file, run_id, all_run_id_info) # executor.submit(upload_json_report) - # Delete downloaded attachments - FL.DeleteFolder(ConfigModule.get_config_value("sectionOne", "download_folder", temp_ini_file)) - # Close websocket connection. if run_id.lower().startswith("debug"): ws.close() diff --git a/Projects/Local_run.json b/Projects/Local_run.json deleted file mode 100644 index 1829f4cf3..000000000 --- a/Projects/Local_run.json +++ /dev/null @@ -1,185 +0,0 @@ -[ - { - "run_id": "WED_LOCAL_RUN", - "is_linked": "", - "device_info": { - "browser_stack": {} - }, - "test_cases": [ - { - "testcase_no": "TEST-5311", - "title": "muhib If element found - 2021-01-11 20:31:31.508629", - "automatability": "Automated", - "debug_steps": "", - "testcase_attachments_links": [], - "step_attachments": [], - "steps": [ - { - "step_id": 6500, - "step_name": "Zeuz demo ai", - "step_sequence": 1, - "step_driver_type": "Built_In_Driver", - "automatablity": "automated", - "step_function": "Sequential Actions", - "step_driver": "Built_In_Driver", - "always_run": false, - "verify_point": true, - "continue_on_fail": true, - "step_time": 59, - "actions": [ - { - "action_name": "None", - "action_disabled": true, - "step_actions": [ - [ - "go to link", - "selenium action", - "https://demo.zeuz.ai/web/level/one/scenerios/login" - ] - ] - }, - { - "action_name": "None", - "action_disabled": true, - "step_actions": [ - [ - "id", - "element parameter", - "username_id" - ], - [ - "true", - "selenium conditional action", - "3-6" - ], - [ - "false", - "selenium conditional action", - "5,6" - ] - ] - }, - { - "action_name": "None", - "action_disabled": true, - "step_actions": [ - [ - "sleep", - "common action", - "5" - ] - ] - }, - { - "action_name": "None", - "action_disabled": true, - "step_actions": [ - [ - "log 2", - "utility action", - "...... Paisi" - ] - ] - }, - { - "action_name": "None", - "action_disabled": true, - "step_actions": [ - [ - "id", - "element parameter", - "username_id" - ], - [ - "click", - "selenium action", - "click" - ] - ] - }, - { - "action_name": "None", - "action_disabled": true, - "step_actions": [ - [ - "log 2", - "utility action", - "...... Pai nai" - ] - ] - }, - { - "action_name": "None", - "action_disabled": true, - "step_actions": [ - [ - "log 2", - "utility action", - "...... Action 6" - ] - ] - }, - { - "action_name": "None", - "action_disabled": true, - "step_actions": [ - [ - "tear down browser", - "selenium action", - "***this field you can ignore , Example \"teardown\" ***" - ] - ] - } - ] - } - ] - } - ], - "dependency_list": { - "Browser": "Chrome", - "Mobile": "Android" - }, - "username": "muhib", - "user_id": 890, - "RunTestQuery": [ - "TEST-5311", - "ChromeHeadless", - "Android", - "muhib_a65f1ae9-9" - ], - "url": "https://qa.zeuz.ai/Home/ManageMachine/", - "dataAttr": [ - "Test Case", - "run_dependencyBrowser", - "run_dependencyMobile" - ], - "filterArray": [ - "AND", - "AND" - ], - "TesterIds": [ - "890" - ], - "EmailIds": [ - "890" - ], - "TestObjective": "Bug-204\u00a0", - "TestMileStone": "Bug Cleanup March 2019 ", - "project_id": "PROJ-17", - "team_id": 2, - "run_time": {}, - "start_date": "2021-01-13", - "end_date": "2021-01-13", - "start": "", - "end": "", - "loop": 1, - "dependency_filter": "", - "branch_version": "", - "threading": false, - "local_run": false, - "take_screenshot": true, - "upload_log_file_only_for_fail": false, - "window_size_x": "", - "window_size_y": "" - } -] \ No newline at end of file diff --git a/node_cli.py b/node_cli.py index e745ae7b5..deaa6a272 100755 --- a/node_cli.py +++ b/node_cli.py @@ -786,16 +786,7 @@ def Local_run(): device_dict = All_Device_Info.get_all_connected_device_info() rem_config = {"local_run": True} ConfigModule.remote_config = rem_config - - path = Path.cwd().parent / "Projects" / "Local_run.json" - with open(path, "r") as f: - Json_data = json.load(f) - if isinstance(Json_data, str): - Json_data = json.loads(Json_data) - all_run_id_info = Json_data if isinstance(Json_data, list) else Json_data["json"] - with open(path, "w") as f: - json.dump(all_run_id_info, f, indent=2) - MainDriverApi.main(device_dict, user_info_object, all_run_id_info) + MainDriverApi.main(device_dict, user_info_object) except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] From 56d1a117119e4902af182bc18451ae31a13b605c Mon Sep 17 00:00:00 2001 From: Muntasib-creator Date: Wed, 10 Feb 2021 01:43:19 +0600 Subject: [PATCH 2/2] Adjusted runtime params with server --- Framework/MainDriverApi.py | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/Framework/MainDriverApi.py b/Framework/MainDriverApi.py index fcb778079..1933cadc5 100644 --- a/Framework/MainDriverApi.py +++ b/Framework/MainDriverApi.py @@ -1455,36 +1455,11 @@ def run_test_case( CommonUtil.CreateJsonReport(TCInfo=after_execution_dict) debug = True if run_id.startswith("debug") else False - # if str(run_id).startswith("debug"): - # debug = True - # debug_steps = debug_info["debug_steps"] - # str_list = str(debug_steps).split("-") - # debug_steps = str_list[0] - # debug_steps = str(debug_steps[1:-1]).split(",") - # - # if debug and ConfigModule.get_config_value("RunDefinition", "local_run") == "False": - # CommonUtil.Join_Thread_and_Return_Result("screenshot") # Let the capturing screenshot end in thread - # executor.submit(cleanup_runid_from_server, run_id) - # executor.submit(start_sending_log_to_server, run_id, temp_ini_file) - # executor.submit(start_sending_shared_var_to_server, run_id) - # executor.submit(start_sending_step_result_to_server, run_id, debug_steps, sTestStepResultList) - # executor.submit(send_debug_data, run_id, "finished", "yes") - if not debug: # if normal run, then write log file and cleanup driver instances CommonUtil.Join_Thread_and_Return_Result("screenshot") # Let the capturing screenshot end in thread cleanup_driver_instances() # clean up drivers shared.Clean_Up_Shared_Variables() # clean up shared variables if ConfigModule.get_config_value("RunDefinition", "local_run") == "False": - # executor.submit( - # write_log_file_for_test_case, - # sTestCaseStatus, - # test_case, - # run_id, - # sTestCaseEndTime, - # TestCaseDuration, - # temp_ini_file, - # send_log_file_only_for_fail, - # ) write_log_file_for_test_case( sTestCaseStatus, test_case, @@ -1725,7 +1700,7 @@ def upload_json_report(Userid, temp_ini_file, run_id, all_run_id_info): break time.sleep(1) else: - print("Could not Upload json report to server") + print("Could not Upload the report to server of run_id '%s'" % run_id) os.unlink(str(zip_path) + ".zip") with open(path, "w") as f: json.dump(json_report, f, indent=2) @@ -1826,7 +1801,8 @@ def main(device_dict, user_info_object): 'Built_In_Driver', 'deepak', 'Built_In_Appium', 'Built_In_NET_Win', 'Jarvis'] final_run_params = {} for param in final_run_params_from_server: - final_run_params[param] = CommonUtil.parse_value_into_object(list(final_run_params_from_server[param].items())[0][1]) + final_run_params[param] = CommonUtil.parse_value_into_object(list(final_run_params_from_server[param].items())[1][1]) + # final_run_params[param] = CommonUtil.parse_value_into_object(list(final_run_params_from_server[param].items())[0][1]) # final_run_params[param] = CommonUtil.parse_value_into_object(final_run_params_from_server[param]["subfield"]) send_log_file_only_for_fail = ConfigModule.get_config_value("RunDefinition", "upload_log_file_only_for_fail") send_log_file_only_for_fail = False if send_log_file_only_for_fail.lower() == "false" else True