browser#
Main class of Browserist that sets the Selenium web driver and contains all helper functions.
Initiates the browser driver whether the settings call for Chrome, Edge, Firefox, etc.
Example
Configuration Classes#
BrowserSettings#
Class to configure the browser driver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type | BrowserType | Set browser type, e.g. Chrome, Edge, Firefox, etc. | EDGE if is_windows() else CHROME |
headless | bool | Run the browser in headless mode. May not be supported by all browsers, or some interaction methods, e.g. select, may not be supported. | False |
disable_images | bool | Neither request nor render images, which typically improves loading speed. May not be supported by all browsers. | False |
page_load_strategy | PageLoadStrategy | Set page load strategy. | NORMAL |
path_to_executable | str | Path | None | If the browser executable isn't in a default folder, select which file to use. | None |
download_dir | str | Path | Set where to save downloads. Default is the | DOWNLOADS_DIR |
screenshot_dir | str | Path | Set where to save sreenshots. Default is the | DOWNLOADS_DIR |
timeout | TimeoutSettings | TimeoutSettings() | |
viewport | DeviceViewportSize | tuple[int, int] | None | Emulate viewport size as device or set custom value in pixels. If not set, the browser's default size is used. | None |
check_connection | bool | Check that there is an internet connection before starting the browser. Bypass the check by setting it to | True |
user_agent | str | Set a custom user agent to override the default user agent. If not set, the browser's default user agent is used. | None |
Example
Use Firefox as browser type:
Use browser in headless mode and with images disabled:
Use custom directory for screenshots:
Use custom viewport size:
Use custom User-agent
in the request header:
How it appears in the terminal: