selenium_drivers package
Submodules
selenium_drivers.base_driver_setup module
- class selenium_drivers.base_driver_setup.BaseDriverSetup(additional_options: dict[str, str | None] | None = None, **kwargs)[source]
Bases:
WebDriverSetup
,ABC
Abstract base class for WebDriver setups. Provides common functionality for handling options and creating WebDriver instances.
- abstract create_default_options() BaseOptions [source]
Create and return default options for the specific browser.
- abstract create_webdriver_instance(service, options) WebDriver [source]
Create the WebDriver instance using the provided service and options.
- get_driver(custom_options: BaseOptions | None = None) WebDriver [source]
Create and return a WebDriver instance with customizable options.
- Parameters:
custom_options (BaseOptions, optional) – If provided, these options
class. (will override the default options set in the)
- Returns:
An instance of the WebDriver with the specified options.
- Return type:
RemoteWebDriver
- Raises:
WebDriverException – If the WebDriver initialization fails.
- class selenium_drivers.base_driver_setup.ChromeDriverSetup(additional_options: dict[str, str | None] | None = None, **kwargs)[source]
Bases:
BaseDriverSetup
- class selenium_drivers.base_driver_setup.EdgeDriverSetup(additional_options: dict[str, str | None] | None = None, **kwargs)[source]
Bases:
BaseDriverSetup
- class selenium_drivers.base_driver_setup.FirefoxDriverSetup(additional_options: dict[str, str | None] | None = None, **kwargs)[source]
Bases:
BaseDriverSetup
- class selenium_drivers.base_driver_setup.IEDriverSetup(additional_options: dict[str, str | None] | None = None, **kwargs)[source]
Bases:
BaseDriverSetup
selenium_drivers.driver_factory module
- selenium_drivers.driver_factory.get_driver(browser: str, **kwargs)[source]
Factory method to instantiate a web driver based on the browser type and custom options.
- Parameters:
browser (str) – The type of browser (‘chrome’, ‘firefox’, ‘edge’, ‘ie’).
**kwargs – Additional options to pass to the driver setup (e.g., proxy, headless).
- Returns:
An instance of a WebDriver for the specified browser.
- Return type:
WebDriver
- Raises:
ValueError – If the browser type is unsupported.
selenium_drivers.webdriver_setup module
- class selenium_drivers.webdriver_setup.WebDriverSetup(proxy: str | None = None, headless: bool = True, sandbox: bool = True, disable_dev_shm_usage: bool = False, ignore_certificate_errors: bool = False, disable_gpu: bool = False, log_level: int = 3, disable_notifications: bool = False, disable_popup_blocking: bool = False, user_agent: str | None = None, window_size: str | None = None, incognito: bool = False, disable_extensions: bool = False, verbose: bool = False, disable_infobars: bool = False, start_fullscreen: bool = False, disable_save_password_bubble: bool = False, safebrowsing_disable_download_protection: bool = False, disable_browser_side_navigation: bool = False, no_proxy_server: bool = False)[source]
Bases:
object
- attempt_recovery_or_exit() None [source]
Attempt to recover from a WebDriver failure by reinitializing the driver.
If the recovery attempt fails, the function will log an error and exit.
- handle_webdriver_error(action: Callable[[], Any], error: Exception, retries: int = 3, delay: int = 2, action_desc: str = 'operating the WebDriver') object [source]
Handles WebDriver errors and attempts to recover from them by retrying the failed action.
- Parameters:
action (Callable) – The action to retry.
error (Exception) – The caught error during WebDriver operation.
retries (int) – Number of retry attempts (default is 3).
delay (int) – Delay between retries (default is 2 seconds).
action_desc (str) – Description of the action being attempted.
- Returns:
The result of the retried action.
- Return type:
Any
- Raises:
Exception – If the retries fail, it raises the final exception.
- selenium_drivers.webdriver_setup.setup_logging(config_path: str = 'config/logging.ini', default_level: int = 20)[source]
Setup logging configuration from a specified path.
Arguments: config_path – string, path to the logging configuration file (default ‘config/logging.ini’) default_level – logging level, default to logging.INFO if configuration file is not found