Skip to content

Conversation

@zbc189
Copy link

@zbc189 zbc189 commented May 21, 2025

Add Browser Tab Management Features

Feature Description

This PR adds browser tab management functionality, enabling users to control and manage browser tabs more efficiently. These new features are particularly useful for automated testing and web operations.

New APIs

  • open_new_tab(url=None): Opens a new tab, with optional URL parameter
  • close_current_tab(): Closes the current tab
  • switch_to_tab(index): Switches to the tab at the specified index
  • get_tab_count(): Returns the number of currently open tabs
  • get_current_tab_index(): Returns the index of the current tab

Implementation Details

  • Implemented tab operations using Selenium WebDriver's window handle management
  • Added tab index management to ensure correct tab operations
  • Implemented wait mechanisms for tab switching to ensure operation reliability

Test Cases

Added comprehensive test cases including:

  • Basic tab operations
  • New tab opening with URL
  • Tab switching
  • Tab closing
  • Tab counting

Documentation Updates

  • Updated API documentation with new feature descriptions and examples
  • Added usage examples and best practices

Backward Compatibility

  • All new features are backward compatible
  • No impact on existing code functionality

Test Results

All test cases have passed, including:

  • Unit tests
  • Integration tests
  • Functional tests

Example Code

from helium import start_chrome, open_new_tab, close_current_tab, switch_to_tab

# Start browser
start_chrome()

# Open new tab
open_new_tab()

# Open new tab with URL
open_new_tab('https://www.google.com')

# Switch tabs
switch_to_tab(0)

# Close current tab
close_current_tab()

Related Issues

[Add links to related issues if any]

Checklist

  • Code follows project coding standards
  • Added necessary test cases
  • Updated relevant documentation
  • All tests passing
  • Code self-reviewed

@CLAassistant
Copy link

CLAassistant commented May 21, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ zbc189
❌ zbc


zbc seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@mherrmann
Copy link
Owner

Hi, thank you for the PR. I'll leave it here for now. If enough users request the feature (or chime in here), then I will merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants