Skip to main content

A powerful and intuitive web automation toolkit built on Selenium.

Project description

Bowser Help Guide

Overview

Bowser is a Python package built on top of Selenium for automated browser interactions. It provides a high-level API for launching Chrome, interacting with elements, and executing common browser tasks with stealth techniques.

Installation

pip install bowser

or for development:

pip install -e .

Class: browser

Initializes a browser session with configurable options.

Arguments:

  • website (str, optional) - The URL to open upon launching the browser.
  • wait_time (int, default=10) - The default timeout in seconds for waiting for elements.
  • hide_selenium (bool, default=True) - If True, applies stealth modifications to evade detection.
  • use_tor (bool, default=False) - If True, routes traffic through Tor for anonymity.
  • headless (bool, default=False) - If True, runs Chrome in headless mode (without UI).
  • crash_prevention (bool, default=True) - If True, adds arguments to prevent Chrome crashes.
  • no_sandbox (bool, default=False) - If True, enables the --no-sandbox argument.
  • print_extra (bool, default=False) - If True, enables additional debugging print statements.
  • add_toolbar (bool, default=True) - If True, injects a debugging toolbar for inspecting elements.
  • custom_options (selenium.webdriver.chrome.options.Options, optional) - Allows users to provide custom Chrome options.

Example:

with browser(website="https://example.com", headless=True) as b:
    b.click(text="Get Started")

Method: find

Finds an element based on a CSS selector, visible text, or tag name.

Arguments:

  • selector (str, default="") - A CSS or XPath selector for locating the element.
  • text (str, optional) - Searches for an element containing the specified visible text.
  • tag (str, default="*") - Filters elements by tag name (e.g., "button", "div").

Returns:

  • WebElement if found, otherwise None.

Example:

element = b.find(selector="h1")
if element:
    print(element.text)

Method: click

Finds an element and clicks it.

Arguments:

  • selector (str, default="") - A CSS or XPath selector for locating the element.
  • text (str, optional) - Clicks an element containing the specified visible text.
  • tag (str, default="*") - Filters elements by tag name.

Example:

b.click(selector="button#submit")
b.click(text="Sign In")

Method: fill

Finds an input field and enters text.

Arguments:

  • selector (str) - A CSS or XPath selector for locating the input field.
  • text_value (str) - The text to enter into the field.
  • text_search (str, optional) - If provided, finds a field near the specified text.
  • tag (str, default="*") - Filters elements by tag name.

Example:

b.fill(selector="input[name='q']", text_value="Python automation")

Method: select

Finds a dropdown and selects an option by visible text.

Arguments:

  • selector (str) - A CSS or XPath selector for locating the dropdown.
  • option_text (str) - The visible text of the option to select.
  • text_search (str, optional) - Finds a dropdown near the specified text.
  • tag (str, default="*") - Filters elements by tag name.

Example:

b.select(selector="select#country", option_text="United States")

Method: get_info

Gets browser and IP details using ipinfo.io.

Arguments:

  • show (bool, default=True) - If True, prints the retrieved information.

Returns:

  • Dictionary containing browser and IP info.

Example:

info = b.get_info()
print(info)

Method: refresh

Reloads the current page.

Arguments:

  • None.

Example:

b.refresh()

Method: keep_awake

Keeps the browser open for a specified duration before quitting.

Arguments:

  • sleep_time (int, default=9999999) - Time in seconds to keep the browser open.

Example:

b.keep_awake(sleep_time=60)

Method: quit

Closes the browser session and cleans up resources.

Arguments:

  • None.

Example:

b.quit()

Method: add_hook

Registers a function to execute before or after specific actions.

Arguments:

  • event (str) - The event name (e.g., "before_click", "after_fill").
  • hook_fn (callable) - The function to execute when the event occurs.

Example:

def log_action():
    print("An action was performed.")

b.add_hook(event="before_click", hook_fn=log_action)

Troubleshooting:

1. ModuleNotFoundError: No module named 'bowser'

  • Ensure you're using the correct Python environment and have installed Bowser properly.
  • Run:
pip install bowser

2. Chrome Binary Not Found

  • Set the CHROME_BIN environment variable or install Chrome manually.

3. Browser Crashes on Start

  • Enable the crash prevention option:
browser(crash_prevention=True)

4. Permissions Issues on Linux

  • Run Bowser with appropriate privileges or manually install Chrome.

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

bowser-0.2.2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

bowser-0.2.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file bowser-0.2.2.tar.gz.

File metadata

  • Download URL: bowser-0.2.2.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.0

File hashes

Hashes for bowser-0.2.2.tar.gz
Algorithm Hash digest
SHA256 0b918ec7f93eb9a241744782719b51134436203c88617e743f2cd02ddfa207a1
MD5 ebd0b91049e254390476032195b67aee
BLAKE2b-256 7ac2ad92720f3496d167a3b2ef0bc3b5efe7a3283a4d6a6e3c9516370f432d61

See more details on using hashes here.

File details

Details for the file bowser-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: bowser-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.0

File hashes

Hashes for bowser-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d6d0925fa22cbd5501faf774c8f1e03691875ca22bb113d14c82508b27e4a88e
MD5 4476cc5189fb05d13d9ef6b14af12323
BLAKE2b-256 b1b21815ae13bae56b8a04eff604ce8ac34ff9edf49231497f55e322c300fdf8

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