Skip to content

Commit 3dd9f86

Browse files
committed
Ignore "javascript:" and "mailto:" links with assert_no_404_errors()
1 parent 51746bf commit 3dd9f86

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,11 @@ def assert_link_status_code_is_not_404(self, link):
16811681
def assert_no_404_errors(self, multithreaded=True):
16821682
""" Assert no 404 errors from page links obtained from:
16831683
"a"->"href", "img"->"src", "link"->"href", and "script"->"src". """
1684-
links = self.get_unique_links()
1684+
all_links = self.get_unique_links()
1685+
links = []
1686+
for link in all_links:
1687+
if "javascript:" not in link and "mailto:" not in link:
1688+
links.append(link)
16851689
if multithreaded:
16861690
from multiprocessing.dummy import Pool as ThreadPool
16871691
pool = ThreadPool(10)
@@ -1690,12 +1694,10 @@ def assert_no_404_errors(self, multithreaded=True):
16901694
pool.join()
16911695
else:
16921696
for link in links:
1693-
if "javascript:" not in link: # Ignore links with JavaScript
1694-
self.assert_link_status_code_is_not_404(link)
1697+
self.assert_link_status_code_is_not_404(link)
16951698
if self.demo_mode:
16961699
messenger_post = ("ASSERT NO 404 ERRORS")
1697-
js_utils.post_messenger_success_message(
1698-
self.driver, messenger_post, self.message_duration)
1700+
self.__highlight_with_assert_success(messenger_post, "html")
16991701

17001702
def print_unique_links_with_status_codes(self):
17011703
""" Finds all unique links in the html of the page source

0 commit comments

Comments
 (0)