Skip to content

Commit 002a323

Browse files
author
Vasil Hristov
authored
Fix debug tests by adding wait step on every click because there is chrome animation. (#256)
Fix Debug Tests by adding wait steps on every click method because chrome animations.
1 parent 329d59c commit 002a323

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

core/utils/chrome/chrome_dev_tools.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def __expand_main_panel(self):
7474
if 'toolbar-state-on' in button.get_attribute("class"):
7575
Log.info('Expand dev tools main pannel.')
7676
button.click()
77+
sleep(1)
7778
else:
7879
Log.info('Dev tools main panel already expanded.')
7980

@@ -105,6 +106,7 @@ def open_tab(self, tab, verify=True):
105106
Log.info('Navigate to {0}.'.format(str(tab)))
106107
element = self.main_panel.find_element(By.ID, str(tab))
107108
element.click()
109+
sleep(1)
108110
self.__refresh_main_panel()
109111
if verify:
110112
if tab == ChromeDevToolsTabs.SOURCES:
@@ -145,13 +147,21 @@ def load_source_file(self, file_name):
145147
popup = self.__get_shadow_element_in_shadow_dom(".vbox.flex-auto", shadow_root)
146148
search_box = popup.find_element(By.CSS_SELECTOR, "span > div > div")
147149
search_box.click()
150+
sleep(1)
148151
search_box.clear()
152+
sleep(1)
149153
search_box.send_keys(file_name)
154+
sleep(1)
150155
search_box.click()
156+
sleep(1)
151157
search_box.clear()
158+
sleep(1)
152159
search_box.send_keys(file_name)
160+
sleep(1)
153161
search_box.click()
162+
sleep(1)
154163
search_box.send_keys(Keys.ENTER)
164+
sleep(1)
155165

156166
def breakpoint(self, line):
157167
"""
@@ -165,6 +175,7 @@ def breakpoint(self, line):
165175
length = len(lines)
166176
assert len(lines) >= line, "Line {0} not found! Total lines of code: {1}".format(str(line), str(length))
167177
lines[line - 1].click()
178+
sleep(1)
168179
Log.info("Toggle breakpoint on line {0}".format(str(line)))
169180

170181
def continue_debug(self):
@@ -176,6 +187,7 @@ def continue_debug(self):
176187
button = debug_panel.find_element(By.CSS_SELECTOR, "button[aria-label='Pause script execution']")
177188
assert 'toolbar-state-on' in button.get_attribute("class"), "Continue button not enabled!"
178189
button.click()
190+
sleep(1)
179191

180192
def __find_line_by_text(self, text):
181193
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):
204216
assert span is not None, "Failed to find element with text " + old_text
205217
x, y = self.chrome.get_absolute_center(span)
206218
pyautogui.click(x, y, clicks=3, interval=0.1)
207-
sleep(0.5)
219+
sleep(1)
208220
pyautogui.doubleClick(x, y)
209-
sleep(0.5)
221+
sleep(1)
210222
pyautogui.typewrite(new_text, interval=0.25)
211-
sleep(0.5)
223+
sleep(1)
212224
pyautogui.press('enter')
213225
sleep(1)
214226
Log.info('Replace "{0}" with "{1}".'.format(old_text, new_text))
@@ -233,6 +245,7 @@ def __clean_console(self):
233245
root_element = self.__expand_shadow_element(root_holder)
234246
button = root_element.find_element(By.CSS_SELECTOR, "button[aria-label='Clear console']")
235247
button.click()
248+
sleep(1)
236249

237250
def type_on_console(self, text, clear_console=True):
238251
"""
@@ -245,6 +258,7 @@ def type_on_console(self, text, clear_console=True):
245258
console = self.chrome.driver.find_element(By.CSS_SELECTOR, "div[id='console-prompt']")
246259
actions = ActionChains(self.chrome.driver)
247260
actions.click(console).perform()
261+
sleep(1)
248262
for _ in range(1, 25):
249263
actions.send_keys(Keys.BACKSPACE).perform()
250264
actions.send_keys(text).perform()
@@ -265,13 +279,15 @@ def add_watch_expression(self, expression, expected_result=None):
265279
if 'true' not in str(expander.get_attribute("aria-expanded")):
266280
Log.info('Expand watch expression bar.')
267281
expander.click()
282+
sleep(1)
268283

269284
# Add expression
270285
tool_bar_holder = self.__expand_shadow_element(watch_bar_holder) \
271286
.find_element(By.CSS_SELECTOR, "div[class='toolbar']")
272287
tool_bar = self.__expand_shadow_element(tool_bar_holder)
273288
add_button = tool_bar.find_element(By.CSS_SELECTOR, "button[aria-label='Add expression']")
274289
add_button.click()
290+
sleep(1)
275291
for _ in range(1, 25):
276292
actions.send_keys(Keys.BACKSPACE).perform()
277293
actions.send_keys(expression).perform()
@@ -299,4 +315,5 @@ def clean_network_tab(self):
299315
root = self.__expand_shadow_element(toolbar)
300316
button = root.find_element(By.CSS_SELECTOR, "button[aria-label='Clear']")
301317
button.click()
318+
sleep(1)
302319
Log.info("Clear Network tab.")

0 commit comments

Comments
 (0)