{"id":22317099,"url":"https://github.com/inquilabee/selenium-tabs","last_synced_at":"2025-07-29T12:30:52.767Z","repository":{"id":57467625,"uuid":"421879899","full_name":"inquilabee/selenium-tabs","owner":"inquilabee","description":" Selenium with tab management in Python.","archived":false,"fork":false,"pushed_at":"2024-11-23T19:26:15.000Z","size":328,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-23T19:30:11.226Z","etag":null,"topics":["browser-automation","python","python-tab-management","selenium","selenium-python","selenium-tabs","tab-management"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inquilabee.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-27T15:48:06.000Z","updated_at":"2024-11-23T19:24:51.000Z","dependencies_parsed_at":"2024-11-23T21:03:59.651Z","dependency_job_id":null,"html_url":"https://github.com/inquilabee/selenium-tabs","commit_stats":null,"previous_names":["theconfused/simpleselenium","inquilabee/selenium-tabs","inquilabee/simpleselenium"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inquilabee%2Fselenium-tabs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inquilabee%2Fselenium-tabs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inquilabee%2Fselenium-tabs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inquilabee%2Fselenium-tabs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inquilabee","download_url":"https://codeload.github.com/inquilabee/selenium-tabs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228012282,"owners_count":17855984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser-automation","python","python-tab-management","selenium","selenium-python","selenium-tabs","tab-management"],"created_at":"2024-12-03T23:08:45.101Z","updated_at":"2025-07-29T12:30:52.753Z","avatar_url":"https://github.com/inquilabee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Selenium Tabs\n\nA Python library that makes browser automation with Selenium more intuitive by providing a tab-centric interface. Manage multiple browser tabs with ease, perform common operations, and interact with web elements using a clean, Pythonic API.\n\n---\n\nAnd guess what! You don't need to manually download drivers for the browser—it's all taken care of by the library. Install and start right away.\n\n**Note:** All testing has been done on Chrome.\n\n## 🚀 Top Features\n\n- **Tab Management**: Open, close, switch, and query tab state with ease.\n- **Element Selection**: Use CSS selectors, jQuery, and PyQuery for powerful element querying.\n- **Page Interaction**: Scroll, click, and wait for elements with robust error handling.\n- **Advanced Features**: Direct driver access, task scheduling, and more.\n- **Automatic Driver Management**: No need to manually download or manage browser drivers.\n\n## 🔧 Installation\n\n```bash\npip install seleniumtabs\n```\n\nOr with Poetry:\n```bash\npoetry add seleniumtabs\n```\n\n## 📋 Requirements\n\n- Python 3.13+\n- Chrome or Firefox browser\n\n## 🚀 Quick Start\n\n```python\nfrom seleniumtabs import Browser\n\n# Create a browser instance and open multiple tabs\nwith Browser(name=\"Chrome\", implicit_wait=10) as browser:\n    # Open multiple websites in different tabs\n    google = browser.open(\"https://google.com\")\n    yahoo = browser.open(\"https://yahoo.com\")\n\n    # Work with tabs\n    print(f\"Current tab: {browser.current_tab}\")\n    print(f\"First tab: {browser.first_tab}\")\n    print(f\"Last tab: {browser.last_tab}\")\n\n    # Switch between tabs\n    yahoo.switch()\n    google.switch()\n\n    # Close a tab\n    yahoo.close()\n```\n\n## ✨ Key Features\n\n### 1. Tab Management\n```python\nwith Browser(name=\"Chrome\") as browser:\n    # Open tabs\n    tab1 = browser.open(\"https://example.com\")\n    tab2 = browser.open(\"https://example.org\")\n\n    # Access tab properties\n    print(tab1.title)  # Page title\n    print(tab1.url)    # Current URL\n    print(tab1.domain) # Domain name\n\n    # Check tab state\n    print(tab1.is_active)  # Is this the active tab?\n    print(tab1.is_alive)   # Is the tab still open?\n```\n\n### 2. Element Selection\n```python\nwith Browser(name=\"Chrome\") as browser:\n    tab = browser.open(\"https://example.com\")\n\n    # CSS Selectors\n    elements = tab.css(\"div.class-name\")\n    for element in elements:\n        print(element.text)\n\n    # Chaining selectors\n    main_content = tab.css(\"main\")[0]\n    links = main_content.css(\"a\")\n\n    # Get element attributes\n    for link in links:\n        print(link.get_attribute(\"href\"))\n```\n\n### 3. Page Interaction\n```python\nwith Browser(name=\"Chrome\") as browser:\n    tab = browser.open(\"https://example.com\")\n\n    # Scrolling\n    tab.scroll_down(times=3)  # Scroll down 3 times\n    tab.scroll_up(times=2)    # Scroll up 2 times\n    tab.scroll_to_bottom()    # Scroll to page bottom\n\n    # Clicking elements\n    element = tab.css(\"button\")[0]\n    tab.click(element)\n\n    # Wait for elements\n    tab.wait_for_presence(\"div\", \"class-name\", wait=10)\n    tab.wait_for_visibility(\"button\", \"submit\", wait=5)\n```\n\n### 4. Advanced Features\n```python\nwith Browser(name=\"Chrome\") as browser:\n    tab = browser.open(\"https://example.com\")\n\n    # jQuery-like operations\n    jq_elements = tab.jq(\"div.class-name\")\n\n    # PyQuery for HTML parsing\n    pq = tab.pyquery\n    text_content = pq.text()\n\n    # Run JavaScript\n    result = tab.run_js(\"return document.title\")\n\n    # Schedule tasks\n    def refresh_page(tab):\n        tab.refresh()\n\n    tab.schedule_task(refresh_page, period=60)  # Refresh every 60 seconds\n```\n\n### Direct Driver Access\n\n- If a feature is not directly available in the `Tab` object, you can access the underlying Selenium WebDriver directly via `tab.driver`.\n- **Example:**\n  ```python\n  # Access driver methods directly\n  tab.driver.execute_script(\"return document.title\")\n  ```\n\n- **Fallback Behavior**: If you call a non-existent method on the `Tab` object, an attempt is made to query `tab.driver.method_name` via `__getattribute__`.\n\n### jQuery Integration\n\n- You can use the `tab.jq` or `tab.jquery` property to run jQuery-like selectors and operations directly on the live browser DOM.\n- Tested features:\n  - Selecting elements with jQuery syntax.\n  - Chaining jQuery selectors.\n  - Accessing and manipulating attributes and text.\n  - Interacting with elements (e.g., click, scroll).\n\n**Example:**\n```python\njq_elements = tab.jq(\"div.class-name\")\nfor el in jq_elements:\n    print(el.text)\n```\n\n---\n\n### PyQuery Integration\n\n- You can use the `tab.pyquery` or `tab.pq` property to parse and query the current page's HTML snapshot using PyQuery (lxml-based).\n- Tested features:\n  - `.items()` for iterating over selections and sub-selections.\n  - `.find()`, `.parent()`, `.children()` for DOM navigation.\n  - `.attr()`, `.text()`, `.html()` for attribute and content access.\n  - Consistency between `tab.pyquery` and `tab.pq`.\n  - Integration with real-world pages (e.g., Yahoo).\n\n**Example:**\n```python\npq = tab.pyquery\nfor link in pq(\"nav a\").items():\n    print(link.attr(\"href\"))\nprint(pq(\"title\").text())\n```\n\n---\n\n## 🔍 Browser Options\n\n```python\nwith Browser(\n    name=\"Chrome\",           # Browser name (\"Chrome\" or \"FireFox\")\n    implicit_wait=10,        # Default wait time for elements\n    headless=False,          # Run browser in headless mode\n    full_screen=True,        # Start browser in full screen\n    page_load_timeout=60     # Page load timeout in seconds\n) as browser:\n    # Your code here\n```\n\n\n## ✅ Tested Features\n\nThis library is thoroughly tested for:\n\n- **Tab Management**: Opening, closing, switching, and querying tab state.\n- **Element Selection**: CSS selector queries, chaining, and attribute access.\n- **Page Interaction**: Scrolling, clicking, and waiting for elements.\n- **Page Loading**: Full and partial page load handling, including timeouts.\n- **Tab Refresh**: Full and partial refresh with robust error handling.\n- **Task Scheduling**: Periodic tab actions (e.g., auto-refresh).\n- **Integration with jQuery and PyQuery** (see below).\n\n---\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## 📝 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finquilabee%2Fselenium-tabs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finquilabee%2Fselenium-tabs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finquilabee%2Fselenium-tabs/lists"}