Improve reliability of the HTML-Inspector and JS-loading code

This commit is contained in:
Michael Mintz 2021-03-23 17:46:17 -04:00
parent bf807a70e0
commit 777b0f73db
2 changed files with 15 additions and 6 deletions

View File

@ -3324,15 +3324,24 @@ class BaseCase(unittest.TestCase):
(https://cdnjs.com/libraries/html-inspector)
Prints the results and also returns them. """
self.__activate_html_inspector()
self.wait_for_ready_state_complete()
script = ("""HTMLInspector.inspect();""")
self.execute_script(script)
try:
self.execute_script(script)
except Exception:
# If unable to load the JavaScript, skip inspection and return.
msg = "(Unable to load HTML-Inspector JS! Inspection Skipped!)"
print("\n" + msg)
return(msg)
time.sleep(0.1)
browser_logs = []
try:
browser_logs = self.driver.get_log('browser')
except (ValueError, WebDriverException):
# If unable to get browser logs, skip the assert and return.
return("(Unable to Inspect HTML! -> Only works on Chrome!)")
msg = "(Unable to Inspect HTML! -> Only works on Chromium!)"
print("\n" + msg)
return(msg)
messenger_library = "//cdnjs.cloudflare.com/ajax/libs/messenger"
url = self.get_current_url()
header = '\n* HTML Inspection Results: %s' % url

View File

@ -407,11 +407,11 @@ def activate_jquery_confirm(driver):
if not is_jquery_activated(driver):
add_js_link(driver, jquery_js)
wait_for_jquery_active(driver, timeout=0.9)
wait_for_jquery_active(driver, timeout=1.2)
add_css_link(driver, jq_confirm_css)
add_js_link(driver, jq_confirm_js)
for x in range(15):
for x in range(int(settings.MINI_TIMEOUT * 10.0)):
# jQuery-Confirm needs a small amount of time to load & activate.
try:
driver.execute_script("jconfirm")
@ -430,14 +430,14 @@ def activate_html_inspector(driver):
return
if not is_jquery_activated(driver):
add_js_link(driver, jquery_js)
wait_for_jquery_active(driver, timeout=1.2)
wait_for_ready_state_complete(driver)
wait_for_angularjs(driver)
wait_for_jquery_active(driver, timeout=1.5)
add_js_link(driver, html_inspector_js)
wait_for_ready_state_complete(driver)
wait_for_angularjs(driver)
for x in range(15):
for x in range(int(settings.MINI_TIMEOUT * 10.0)):
# HTML-Inspector needs a small amount of time to load & activate.
try:
driver.execute_script("HTMLInspector")