Skip to content

Commit 0064e85

Browse files
committed
Clear out console logs before opening or refreshing pages
1 parent 3da18b0 commit 0064e85

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def __init__(self, *args, **kwargs):
9898
def open(self, url):
9999
""" Navigates the current browser window to the specified page. """
100100
self.__last_page_load_url = None
101+
js_utils.clear_out_console_logs(self.driver)
101102
if url.startswith("://"):
102103
# Convert URLs such as "://google.com" into "https://google.com"
103104
url = "https" + url
@@ -424,6 +425,7 @@ def submit(self, selector, by=By.CSS_SELECTOR):
424425

425426
def refresh_page(self):
426427
self.__last_page_load_url = None
428+
js_utils.clear_out_console_logs(self.driver)
427429
self.driver.refresh()
428430
self.wait_for_ready_state_complete()
429431

seleniumbase/fixtures/js_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,15 @@ def get_drag_and_drop_script():
790790
return script
791791

792792

793+
def clear_out_console_logs(driver):
794+
try:
795+
# Clear out the current page log before navigating to a new page
796+
# (To make sure that assert_no_js_errors() uses current results)
797+
driver.get_log('browser')
798+
except Exception:
799+
pass
800+
801+
793802
@decorators.deprecated("Use re.escape() instead, which does what you want!")
794803
def _jq_format(code):
795804
"""

0 commit comments

Comments
 (0)