code: def has_no_console_errors(
      pytestconfig: config.Config,
  ) -> Callable[[WebDriver], bool | NoReturn]:
      """Provide a function to assert no browser console errors are present.
  
      Unfortunately logs are only accessibly with Chrome web driver, see e.g.
  
          https://github.com/mozilla/geckodriver/issues/284
  
      For non-Chrome webdrivers this check always returns True.
  
      """
      driver_name: str = pytestconfig.getoption("driver").lower()
  
      if driver_name == "chrome":
  
          def func(driver: WebDriver) -> bool | NoReturn:
              logs = driver.get_log("browser")
              severe_errors = [
                  x for x in logs if x.get("level") == "SEVERE"
              ]
              non_network_errors = [
                  l for l in severe_errors if l.get("type") != "network"
              ]
  
              if len(non_network_errors) == 0:
                  if len(severe_errors) != 0:
                      warn(
                          f"There were severe network errors (this may or may not have affected your test): {severe_errors}"
                      )
                  return True
  
              # XXX: no return should be needed with NoReturn type (type-checker bug?)
              return pytest.fail(
                  f"Console errors: {non_network_errors}"
              )
  
      else:
  
          def func(driver: WebDriver) -> bool | NoReturn:
              return True
  
      return func
  
file_path: bokeh/tests/support/plugins/selenium.py
imports: from __future__ import annotations
  import logging
  from shutil import which
  from typing import TYPE_CHECKING, Callable, Iterator, NoReturn, Sequence
  from warnings import warn
  import pytest
label_desc: Use image node_id 3 for calling a global function with example usage: has_no_console_errors(pytestconfig) and returns: func, pytest, True, True