Skip to main content

Selenium with tab management in Python

Project description

Selenium Tabs: Enhanced Tab Management for Selenium

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

Installation

Install Selenium Tabs from PyPI with ease:

pip install seleniumtabs

Core Idea

In Selenium Tabs, 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
  • Close a tab
  • Access page source, title, and headings
  • Select elements and perform actions using Jquery
  • Perform actions on a specific tab (e.g., click, scroll, close)
  • 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 without making explicit switches to a specific tab.

Features

Selenium Tabs 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, waiting for conditions, finding and more
  • Access to the underlying Selenium driver object for advanced usage
  • Access driver methods directly on tabs
  • Automatic User agent selection based on set browser
  • Basic steps to avoid getting flagged as an automation script by websites
  • Use the all-powerful pyquery object access on each tab
  • Execute jquery functions using .jq or .jquery attributes

Usage

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

Browser

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

from seleniumtabs import Browser, Tab


with Browser(name="Chrome", implicit_wait=10) as browser:
    google = 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(times=2)
    yahoo.scroll_to_bottom()

    # Working with tabs
    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
    bing.close() # Or browser.close_tab(bing)

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

    # Accessing the driver object
    print(google.driver.title, google.title) # Should output same value

    # Directly access driver methods and attributes
    print(google.current_window_handle, google.tab_handle)
    google.refresh()

    # PyQuery
    print(google.pyquery.text())
    print(google.pq.size())

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.5.3.tar.gz (14.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.5.3-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for seleniumtabs-0.5.3.tar.gz
Algorithm Hash digest
SHA256 466b78b39f49918a7292438dfa0138904c558d0980f95909f298f5813f7a2198
MD5 76d8a504eded113620038309318598c0
BLAKE2b-256 940e6f5e4fff1c8bb40dd6f2c91ac72b9c0f71c73ea44dc6d0627c3eb48c3dc4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for seleniumtabs-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7130c43a0580b56d29b5ff0e6bf2f99994661ae57368504c057e6efb37836bd5
MD5 0ef263ce7186a1cb5d06efe9996172bd
BLAKE2b-256 0b823be6ba8dd59951cf17fb108c9fc982883bbeae6ea1f5b08a9e1e5e23196c

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