Skip to main content

BrowserManager Library

Description

The BrowserManager Library simplifies browser automation and management by detecting installed browsers, selecting user profiles, and integrating with Selenium WebDriver for automated testing and tasks. The library abstracts the logic for locating installed browsers on the system, configuring user profiles, and managing drivers, with support for Windows, Linux, and macOS.

Features

  • Automatic Detection of Installed Browsers: Supports Chrome, Chromium, Firefox, Microsoft Edge, Safari, Opera, and Internet Explorer.
  • Profile Management: Lists and selects user profiles for the browsers.
  • Selenium WebDriver Automation: Easy integration with Selenium for browser automation.

Installation

To install the library, run:

pip install browser_manager

Usage Examples

Example Usage with BrowserManager

Here's a example of how to use the library to automate a browser session:

from browser_manager.manager.selenium import BrowserManager
from browser_manager.browser.selenium import Firefox

# Create an instance of the BrowserManager class
browser_manager = BrowserManager()

# Select the preferred browser by passing the desired browser class (Firefox)
# If it's not available, a selection will be presented.
browser = browser_manager.select_browser(Firefox)
print(f"Selected browser: {browser.name}")  # Print the name of the selected browser

# Select the preferred profile for the chosen browser by passing the profile name "default-release"
# If it's not available, a selection will be presented.
# Selecting a profile is optional
profile = browser.select_profile("default-release")
print(f"Selected profile: {profile.name}")  # Print the name of the selected profile
print(f"Selected profile folder: {profile.path}")  # Print the path of the selected profile

# Get the driver for the selected browser
driver = browser.get_driver()
print(f"Driver Path: {browser.driver_path}")  # Print the path of the driver
print(f"Driver: {driver}")  # Print the driver object

# Navigate to Google
driver.get("https://google.com")
print(driver.title)

# Wait for user input before closing the browser session
input("Press Enter to close the browser...")

# Close the browser session
driver.quit()

Example Usage Directly from Firefox

Here’s how to use the Firefox class directly:

from browser_manager.browser.selenium import Firefox

# Create an instance of the Firefox browser
browser = Firefox()

# Select the preferred profile for the chosen browser by passing the profile name "default-release"
# If it's not available, a selection will be presented.
# Selecting a profile is optional
profile = browser.select_profile("default-release")
print(f"Selected profile: {profile.name}")  # Print the name of the selected profile
print(f"Selected profile folder: {profile.path}")  # Print the path of the selected profile

# Get the driver for the selected browser
driver = browser.get_driver()
print(f"Driver Path: {browser.driver_path}")  # Print the path of the driver
print(f"Driver: {driver}")  # Print the driver object

# Navigate to Google
driver.get("https://google.com")
print(driver.title)

# Wait for user input before closing the browser session
input("Press Enter to close the browser...")

# Close the browser session
driver.quit()

Basic Usage Example

Here’s a simple example of how to directly use the Firefox browser with the BrowserManager library:

from browser_manager.browser.selenium import Firefox

# Create an instance of the Firefox browser
driver = Firefox().get_driver()

# Navigate to Google
driver.get("https://google.com")
print(driver.title)

# Wait for user input before closing the browser session
input("Press Enter to close the browser...")

# Close the browser session
driver.quit()

Supported Platforms

  • Windows
  • Linux
  • macOS

License

This project is licensed under the MIT License.

Contact

For any inquiries, please contact: contato@tpereira.com.br

Contributing

Feel free to submit pull requests or open issues to improve the library. Please ensure that your code follows the repository's coding standards and is well-documented.

Metadata

Release files for browser_manager 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for browser_manager 1.0.5
File Size Uploaded
browser_manager-1.0.5.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for browser_manager 1.0.5
File Interpreter ABI Platform
browser_manager-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 42.1 kB

Release files / browser_manager-1.0.5.tar.gz

Download URL browser_manager-1.0.5.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
833d1928f21d6751696c35f65699e437a84413213b0d00f7562362625ce12eb5
BLAKE2b-256 checksum
How to use checksums
968e9019d6133567522f1eacae47c7ba633a8832302288c9b6d38854ed881d6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Windows/11

Release files / browser_manager-1.0.5-py3-none-any.whl

Download URL browser_manager-1.0.5-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afd9d6450d38d8989d7d56f41daf7eb31faf967ed10d67623ba1042c1796c261
BLAKE2b-256 checksum
How to use checksums
8d652c6e84ce20886caa2d2982afafd470f3af16e6f8aa6cc21348603c3230ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Windows/11

Release history Release notifications | RSS feed

This release

1.0.5 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page