Skip to main content

The BrowserManager Library simplifies browser automation and management...

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

browser_manager-1.0.5.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

browser_manager-1.0.5-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file browser_manager-1.0.5.tar.gz.

File metadata

  • Download URL: browser_manager-1.0.5.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Windows/11

File hashes

Hashes for browser_manager-1.0.5.tar.gz
Algorithm Hash digest
SHA256 833d1928f21d6751696c35f65699e437a84413213b0d00f7562362625ce12eb5
MD5 00d2cd5d8b272883f6e3e49a88e1d9b9
BLAKE2b-256 968e9019d6133567522f1eacae47c7ba633a8832302288c9b6d38854ed881d6b

See more details on using hashes here.

File details

Details for the file browser_manager-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: browser_manager-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Windows/11

File hashes

Hashes for browser_manager-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 afd9d6450d38d8989d7d56f41daf7eb31faf967ed10d67623ba1042c1796c261
MD5 082003b6991f9cd1719b0f08f0d152f4
BLAKE2b-256 8d652c6e84ce20886caa2d2982afafd470f3af16e6f8aa6cc21348603c3230ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page