From d2df4daaaa927bf819b7ff4ad800bede2b069e70 Mon Sep 17 00:00:00 2001 From: vhristov5555 Date: Wed, 3 Jul 2019 16:16:29 +0300 Subject: [PATCH 1/5] Fix Debug Tests. --- core/utils/chrome/chrome_dev_tools.py | 1 + core/utils/device/simctl.py | 2 +- core/utils/run.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/utils/chrome/chrome_dev_tools.py b/core/utils/chrome/chrome_dev_tools.py index b7fa0775..7035c630 100644 --- a/core/utils/chrome/chrome_dev_tools.py +++ b/core/utils/chrome/chrome_dev_tools.py @@ -274,6 +274,7 @@ def add_watch_expression(self, expression, expected_result=None): for _ in range(1, 25): actions.send_keys(Keys.BACKSPACE).perform() actions.send_keys(expression).perform() + sleep(1) Log.info('Add watch expression: {0}'.format(expression)) # Refresh diff --git a/core/utils/device/simctl.py b/core/utils/device/simctl.py index 7e7e2e0a..2e19a927 100644 --- a/core/utils/device/simctl.py +++ b/core/utils/device/simctl.py @@ -167,7 +167,7 @@ def is_process_running(simulator_info, app_id): def get_log_file(device_id): command = 'spawn {0} log stream --level=debug'.format(device_id) Process.kill_by_commandline(command) - log_file = Simctl.run_simctl_command(command=command.format(device_id), wait=False).log_file + log_file = Simctl.run_simctl_command(command=command, wait=False).log_file if File.exists(log_file): Log.debug('Log of {0} redirected to {1}'.format(device_id, log_file)) return log_file diff --git a/core/utils/run.py b/core/utils/run.py index 90269888..923f2d30 100644 --- a/core/utils/run.py +++ b/core/utils/run.py @@ -27,7 +27,7 @@ def run(cmd, cwd=Settings.TEST_RUN_HOME, wait=True, timeout=600, fail_safe=False, register=True, log_level=logging.DEBUG): # Init result values - time_string = datetime.now().strftime('%Y_%m_%d_%H_%M_%S') + time_string = datetime.now().strftime('%Y_%m_%d_%H_%M_%S_%f') log_file = os.path.join(Settings.TEST_OUT_LOGS, 'command_{0}.txt'.format(time_string)) complete = False duration = None From 70b7ff61c1ea600437b422cbbbe578ebe749b0f1 Mon Sep 17 00:00:00 2001 From: vhristov5555 Date: Wed, 3 Jul 2019 17:25:13 +0300 Subject: [PATCH 2/5] Fix Debug Tests. --- core/utils/chrome/chrome_dev_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/utils/chrome/chrome_dev_tools.py b/core/utils/chrome/chrome_dev_tools.py index 7035c630..b4def41f 100644 --- a/core/utils/chrome/chrome_dev_tools.py +++ b/core/utils/chrome/chrome_dev_tools.py @@ -274,7 +274,7 @@ def add_watch_expression(self, expression, expected_result=None): for _ in range(1, 25): actions.send_keys(Keys.BACKSPACE).perform() actions.send_keys(expression).perform() - sleep(1) + sleep(3) Log.info('Add watch expression: {0}'.format(expression)) # Refresh From 7957a1f98d6f085176ecff09dc8b84c44becb620 Mon Sep 17 00:00:00 2001 From: vhristov5555 Date: Wed, 3 Jul 2019 17:33:49 +0300 Subject: [PATCH 3/5] Fix Debug Tests. --- core/utils/chrome/chrome_dev_tools.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/utils/chrome/chrome_dev_tools.py b/core/utils/chrome/chrome_dev_tools.py index b4def41f..821d936b 100644 --- a/core/utils/chrome/chrome_dev_tools.py +++ b/core/utils/chrome/chrome_dev_tools.py @@ -210,7 +210,7 @@ def edit_text(self, old_text, new_text): pyautogui.typewrite(new_text, interval=0.25) sleep(0.5) pyautogui.press('enter') - sleep(0.5) + sleep(1) Log.info('Replace "{0}" with "{1}".'.format(old_text, new_text)) def doubleclick_line(self, text): @@ -222,6 +222,7 @@ def doubleclick_line(self, text): assert line is not None, "Failed to find line with text " + text x, y = self.chrome.get_absolute_center(line) pyautogui.doubleClick(x, y) + sleep(1) Log.info('Double click line with text "{0}".'.format(text)) def __clean_console(self): From fd2c092205d550a28b0cbf1fa7d75eeb04e9312e Mon Sep 17 00:00:00 2001 From: vhristov5555 Date: Thu, 4 Jul 2019 13:50:41 +0300 Subject: [PATCH 4/5] Fix Debug Tests by adding wait steps on every click method because chrome animations. --- core/utils/chrome/chrome_dev_tools.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/core/utils/chrome/chrome_dev_tools.py b/core/utils/chrome/chrome_dev_tools.py index 821d936b..a5d424b5 100644 --- a/core/utils/chrome/chrome_dev_tools.py +++ b/core/utils/chrome/chrome_dev_tools.py @@ -74,6 +74,7 @@ def __expand_main_panel(self): if 'toolbar-state-on' in button.get_attribute("class"): Log.info('Expand dev tools main pannel.') button.click() + sleep(1) else: Log.info('Dev tools main panel already expanded.') @@ -105,6 +106,7 @@ def open_tab(self, tab, verify=True): Log.info('Navigate to {0}.'.format(str(tab))) element = self.main_panel.find_element(By.ID, str(tab)) element.click() + sleep(1) self.__refresh_main_panel() if verify: if tab == ChromeDevToolsTabs.SOURCES: @@ -145,13 +147,21 @@ def load_source_file(self, file_name): popup = self.__get_shadow_element_in_shadow_dom(".vbox.flex-auto", shadow_root) search_box = popup.find_element(By.CSS_SELECTOR, "span > div > div") search_box.click() + sleep(1) search_box.clear() + sleep(1) search_box.send_keys(file_name) + sleep(1) search_box.click() + sleep(1) search_box.clear() + sleep(1) search_box.send_keys(file_name) + sleep(1) search_box.click() + sleep(1) search_box.send_keys(Keys.ENTER) + sleep(1) def breakpoint(self, line): """ @@ -165,6 +175,7 @@ def breakpoint(self, line): length = len(lines) assert len(lines) >= line, "Line {0} not found! Total lines of code: {1}".format(str(line), str(length)) lines[line - 1].click() + sleep(1) Log.info("Toggle breakpoint on line {0}".format(str(line))) def continue_debug(self): @@ -176,6 +187,7 @@ def continue_debug(self): button = debug_panel.find_element(By.CSS_SELECTOR, "button[aria-label='Pause script execution']") assert 'toolbar-state-on' in button.get_attribute("class"), "Continue button not enabled!" button.click() + sleep(1) def __find_line_by_text(self, text): shadow_dom_element = self.chrome.driver.find_element(By.CSS_SELECTOR, "div[id='elements-content'] > div") @@ -204,11 +216,11 @@ def edit_text(self, old_text, new_text): assert span is not None, "Failed to find element with text " + old_text x, y = self.chrome.get_absolute_center(span) pyautogui.click(x, y, clicks=3, interval=0.1) - sleep(0.5) + sleep(1) pyautogui.doubleClick(x, y) - sleep(0.5) + sleep(1) pyautogui.typewrite(new_text, interval=0.25) - sleep(0.5) + sleep(1) pyautogui.press('enter') sleep(1) Log.info('Replace "{0}" with "{1}".'.format(old_text, new_text)) @@ -233,6 +245,7 @@ def __clean_console(self): root_element = self.__expand_shadow_element(root_holder) button = root_element.find_element(By.CSS_SELECTOR, "button[aria-label='Clear console']") button.click() + sleep(1) def type_on_console(self, text, clear_console=True): """ @@ -245,6 +258,7 @@ def type_on_console(self, text, clear_console=True): console = self.chrome.driver.find_element(By.CSS_SELECTOR, "div[id='console-prompt']") actions = ActionChains(self.chrome.driver) actions.click(console).perform() + sleep(1) for _ in range(1, 25): actions.send_keys(Keys.BACKSPACE).perform() actions.send_keys(text).perform() @@ -265,6 +279,7 @@ def add_watch_expression(self, expression, expected_result=None): if 'true' not in str(expander.get_attribute("aria-expanded")): Log.info('Expand watch expression bar.') expander.click() + sleep(1) # Add expression tool_bar_holder = self.__expand_shadow_element(watch_bar_holder) \ @@ -272,6 +287,7 @@ def add_watch_expression(self, expression, expected_result=None): tool_bar = self.__expand_shadow_element(tool_bar_holder) add_button = tool_bar.find_element(By.CSS_SELECTOR, "button[aria-label='Add expression']") add_button.click() + sleep(1) for _ in range(1, 25): actions.send_keys(Keys.BACKSPACE).perform() actions.send_keys(expression).perform() @@ -299,4 +315,5 @@ def clean_network_tab(self): root = self.__expand_shadow_element(toolbar) button = root.find_element(By.CSS_SELECTOR, "button[aria-label='Clear']") button.click() + sleep(1) Log.info("Clear Network tab.") From a11b1215ce71553e61fc888f48a3db96862949a9 Mon Sep 17 00:00:00 2001 From: vhristov5555 Date: Thu, 4 Jul 2019 15:58:06 +0300 Subject: [PATCH 5/5] Fix Debug Tests. --- core/utils/chrome/chrome_dev_tools.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/utils/chrome/chrome_dev_tools.py b/core/utils/chrome/chrome_dev_tools.py index a5d424b5..b0f5e9c7 100644 --- a/core/utils/chrome/chrome_dev_tools.py +++ b/core/utils/chrome/chrome_dev_tools.py @@ -234,7 +234,7 @@ def doubleclick_line(self, text): assert line is not None, "Failed to find line with text " + text x, y = self.chrome.get_absolute_center(line) pyautogui.doubleClick(x, y) - sleep(1) + sleep(2) Log.info('Double click line with text "{0}".'.format(text)) def __clean_console(self): @@ -291,6 +291,8 @@ def add_watch_expression(self, expression, expected_result=None): for _ in range(1, 25): actions.send_keys(Keys.BACKSPACE).perform() actions.send_keys(expression).perform() + sleep(1) + actions.send_keys(Keys.ENTER).perform() sleep(3) Log.info('Add watch expression: {0}'.format(expression))