@@ -2022,6 +2022,49 @@ def assert_no_js_errors(self):
2022
2022
messenger_post = ("ASSERT NO JS ERRORS" )
2023
2023
self .__highlight_with_assert_success (messenger_post , "html" )
2024
2024
2025
+ def __activate_html_inspector (self ):
2026
+ js_utils .activate_html_inspector (self .driver )
2027
+
2028
+ def inspect_html (self ):
2029
+ """ Inspects the Page HTML with HTML-Inspector.
2030
+ (https://github.com/philipwalton/html-inspector)
2031
+ (https://cdnjs.com/libraries/html-inspector)
2032
+ Prints the results and also returns them. """
2033
+ self .__activate_html_inspector ()
2034
+ script = ("""HTMLInspector.inspect();""" )
2035
+ self .execute_script (script )
2036
+ time .sleep (0.1 )
2037
+ browser_logs = []
2038
+ try :
2039
+ browser_logs = self .driver .get_log ('browser' )
2040
+ except (ValueError , WebDriverException ):
2041
+ # If unable to get browser logs, skip the assert and return.
2042
+ return ("(Unable to Inspect HTML! -> Only works on Chrome!)" )
2043
+ messenger_library = "//cdnjs.cloudflare.com/ajax/libs/messenger"
2044
+ url = self .get_current_url ()
2045
+ header = '\n * HTML Inspection Results: %s' % url
2046
+ results = [header ]
2047
+ row_count = 0
2048
+ for entry in browser_logs :
2049
+ message = entry ['message' ]
2050
+ if "0:6053 " in message :
2051
+ message = message .split ("0:6053" )[1 ]
2052
+ message = message .replace ("\\ u003C" , "<" )
2053
+ if message .startswith (' "' ) and message .count ('"' ) == 2 :
2054
+ message = message .split ('"' )[1 ]
2055
+ message = "X - " + message
2056
+ if messenger_library not in message :
2057
+ if message not in results :
2058
+ results .append (message )
2059
+ row_count += 1
2060
+ if row_count > 0 :
2061
+ results .append ('* (See the Console output for details!)' )
2062
+ else :
2063
+ results .append ('* (No issues detected!)' )
2064
+ results = '\n ' .join (results )
2065
+ print (results )
2066
+ return (results )
2067
+
2025
2068
def get_google_auth_password (self , totp_key = None ):
2026
2069
""" Returns a time-based one-time password based on the
2027
2070
Google Authenticator password algorithm. Works with Authy.
0 commit comments