code: def driver(pytestconfig: config.Config) -> Iterator[WebDriver]:
      """Select and configure a Selenium webdriver for integration tests."""
      driver_name: str = pytestconfig.getoption(
          "driver", "chrome"
      ).lower()
  
      def chrome() -> WebDriver:
          for executable in [
              "chromedriver",
              "chromium.chromedriver",
              "chromedriver-binary",
          ]:
              executable_path = which(executable)
              if executable_path is not None:
                  break
          else:
              raise RuntimeError(
                  "chromedriver or its variant is not installed or not present on PATH"
              )
  
          from selenium.webdriver.chrome.options import Options
          from selenium.webdriver.chrome.service import Service
          from selenium.webdriver.chrome.webdriver import (
              WebDriver as Chrome,
          )
  
          service = Service(executable_path)
          options = Options()
          options.add_argument("--headless")
          options.add_argument("--no-sandbox")
          options.add_argument("--window-size=1920x1080")
  
          return Chrome(service=service, options=options)
  
      def firefox() -> WebDriver:
          from selenium.webdriver.firefox.options import Options
          from selenium.webdriver.firefox.webdriver import (
              WebDriver as Firefox,
          )
  
          options = Options()
          options.add_argument("--headless")
          options.add_argument("--window-size=1920x1080")
          return Firefox(options=options)
  
      def safari() -> WebDriver:
          from selenium.webdriver.safari.webdriver import (
              WebDriver as Safari,
          )
  
          return Safari()
  
      driver: WebDriver
      if driver_name == "chrome":
          driver = chrome()
      elif driver_name == "firefox":
          driver = firefox()
      elif driver_name == "safari":
          driver = safari()
      else:
          raise ValueError("expected 'chrome', 'firefox' or 'safari'")
  
      driver.implicitly_wait(10)
      yield driver
      driver.quit()
  
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 2 for calling a global function with example usage: driver(pytestconfig) and returns: Chrome, Firefox, Safari