Skip to main content

Selenium with tab management in Python

Project description

Simple Selenium: Enhanced Tab Management for Selenium

Simplify your web automation tasks with Simple Selenium, a Python package that takes Selenium to the next level with streamlined tab management and additional features.

Installation

Install Simple Selenium from PyPI with ease:

pip install selenium-tabs

Core Idea

In Simple Selenium, a browser contains multiple tabs, enabling you to interact with web pages more efficiently. You can perform various actions on both Tab and Browser objects, making web automation a breeze.

Actions/Activities on Tab Objects:

  • Check tab status (open/closed)
  • Switch to a specific tab
  • Access page source, title, and headings
  • Inject jQuery and select elements
  • Perform actions on a specific tab (e.g., click, scroll)
  • CSS selection made easy

Actions/Activities on Browser Objects:

  • Open new tabs with URLs
  • Retrieve a list of open tabs
  • Switch to a specific tab (first, last, or any)
  • Close a tab
  • Close the entire browser

Working with Driver Objects

A driver object is available on any Tab object, allowing you to access the browser/driver object and use Selenium methods when needed.

Features

Simple Selenium offers a range of features to enhance your web automation tasks:

  • Effortless tab management
  • Seamless tab switching
  • Real-time tab status tracking
  • Convenient tab closure
  • Built-in functions for scrolling, clicking, and more
  • Access to the underlying Selenium driver object for advanced usage

Usage

To get started with Simple Selenium, create a Browser object and open tabs using the open method:

Browser

from seleniumtabs import Browser, Tab

# Create a `Browser` object, specifying the browser name (e.g., "Chrome").
# The project automatically downloads drivers.

with Browser(name="Chrome", implicit_wait=10) as browser:
    google: Tab = browser.open("https://google.com")
    yahoo = browser.open("https://yahoo.com")
    bing = browser.open("https://bing.com")
    duck_duck = browser.open("https://duckduckgo.com/")

    # Scroll on the page (example)
    yahoo.scroll_to_bottom()

    # Working with tabs
    assert len(browser.tabs) == 4
    assert google in browser.tabs
    assert browser.tabs[0] == google

    for tab in browser.tabs:
        print(tab)

    print(browser.tabs)
    print(browser.current_tab)

    # Selecting elements with JQuery (using Browserjquery package)
    print(yahoo.jq("a"))

    # Selecting using CSS Selectors (no JQuery needed)
    for item in yahoo.css(".stream-items"):
        for a in item.css("a"):
            print(a, a.text)

    # Some `Tab` attributes/properties
    print(google.title)
    print(google.url)
    print(google.page_source)

    # Closing a tab
    browser.close_tab(bing)

    # Switching to a tab
    yahoo.switch()
    google.switch()

    # Accessing the driver object
    print(google.driver.title, google.title)

TODO

  • Complete documentation

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

seleniumtabs-0.4.4.tar.gz (37.9 kB view details)

Uploaded Source

Built Distribution

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

seleniumtabs-0.4.4-py3-none-any.whl (40.9 kB view details)

Uploaded Python 3

File details

Details for the file seleniumtabs-0.4.4.tar.gz.

File metadata

  • Download URL: seleniumtabs-0.4.4.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1011-azure

File hashes

Hashes for seleniumtabs-0.4.4.tar.gz
Algorithm Hash digest
SHA256 e25c2c3c23fc4f94315f2c1454d711c8f64df8e5a5b8128bdce3988b525f3806
MD5 35155137ba5533b054d6aba3fd3a91be
BLAKE2b-256 d530e8c87eb611553bd33d80d7357e79b5731a0abde024ff26b3e8a90da4e40b

See more details on using hashes here.

File details

Details for the file seleniumtabs-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: seleniumtabs-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 40.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1011-azure

File hashes

Hashes for seleniumtabs-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c24098a7cf3fa7a8974a30357d0506ce1272e8c8aa06f37a82d1832ed42d2710
MD5 765db86c455dcbe9abfbd954b08bf217
BLAKE2b-256 a9db151ff1684996996edc2b58ba170e06fc69139542fb2ef6d3fc6e6c96e63a

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