Skip to main content

A library for 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 import BrowserManager
from browser_manager.browser 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 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 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-0.1.0.tar.gz (7.9 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-0.1.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: browser_manager-0.1.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for browser_manager-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ef6658df329da7ee28e42177529fcc8da3291935fa202da34dd98cf8a2c6e073
MD5 5dadb4e250400fefdb155700038de546
BLAKE2b-256 4c3d205fba3be70ef82129d92e0ce0de5064bb6b5d8db2d3466dee9f06684e9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for browser_manager-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 acabfee0e287f5e09bf46bda0e1bf3163b3369e4a6f3887a0ef749ebe3df2ef2
MD5 66bca699678fa3109233f60ccbc643b2
BLAKE2b-256 fa3d280b499ce463d51510925c958c51eab55bd2ff9dd8be06dc0fe8b304a398

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