Skip to content

[Task-2247] Named Browser Sessions For Dual-Driver Browser Instances#671

Open
nasif-z wants to merge 13 commits intoplaywright-asyncfrom
task-2247-browser-sessions
Open

[Task-2247] Named Browser Sessions For Dual-Driver Browser Instances#671
nasif-z wants to merge 13 commits intoplaywright-asyncfrom
task-2247-browser-sessions

Conversation

@nasif-z
Copy link
Copy Markdown
Collaborator

@nasif-z nasif-z commented Mar 5, 2026

This PR introduces session-based browser isolation to allow testers to easily spawn fresh browser windows and intuitively interact with them individually. It follows the same session model used in database actions.


Changes

  • Session Isolation: Added browser_sessions shared variable to hold necessary browser driver information whenever opening new browser windows. By default, generates a browser_session named default.
  • Existing Variables: The sessions simply contains the pointers to the driver variables that were already in use.
  • Dynamic Ports: Automatically assigns unique remote debugging ports (9222–9322) for dual-driver CDP connections.
  • Dual Driver Support: Implemented in both Selenium and Playwright. Commonly used actions were modified to check if session is available and switches the active driver accordingly.
  • Targeted Actions & Teardown: Web functions now accept a session parameter to only execute the actions on specific instances without affecting others.

Backwards Compatibility

  • No Breaking Changes: If the session parameter is omitted, the framework defaults to the legacy single-instance behavior.
  • Legacy Parameters: driverid support is maintained for Selenium.

Usage

Add row in action in this format: session | optional parameter | session name (string)

1. Selenium Multi-Session

Pass a unique string to the session parameter to spawn separate windows.

# Session A
Go_To_Link([
    ("session", "optional parameter", "user_1"),
    ("go to link", "selenium action", "https://google.com")
])

# Session B
Go_To_Link([
    ("session", "optional parameter", "user_2"),
    ("go to link", "selenium action", "https://bing.com")
])

2. Apply action on specific session

# Will apply the click action on the browser with session name admin_auth
# even when there are multiple sessions active
Click_Element([
    ("session", "optional parameter", "admin_auth"),
    ("id", "element parameter", "login-btn"),
    ("click", "playwright action", "click")
])

3. Specific Session Cleanup

Tear_Down_Selenium([
    ("session", "optional parameter", "user_1"),
    ("tear down", "selenium action", "tear down")
])

4. Without "session" parameter

Omitting the session parameter in step/action data will preserve the behavior as it was before the addition of this feature.

@nasif-z nasif-z requested a review from sazid March 5, 2026 16:54
@nasif-z nasif-z self-assigned this Mar 5, 2026
@nasif-z nasif-z changed the title [Task-2247] Named Browser Sessions: Isolated Dual-Driver Browser Instances [Task-2247] Named Browser Sessions For Dual-Driver Browser Instances Mar 5, 2026
@sazid
Copy link
Copy Markdown
Member

sazid commented Mar 6, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8e79d1b04

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py
Comment thread Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py Outdated
Comment thread Framework/Built_In_Automation/Web/Playwright/BuiltInFunctions.py
@sazid
Copy link
Copy Markdown
Member

sazid commented Mar 7, 2026

@nasif-z check the comments

@sazid sazid marked this pull request as draft March 7, 2026 19:00
@nasif-z nasif-z marked this pull request as ready for review March 25, 2026 13:07
Base automatically changed from req-81-playwright-selenium-dual-driver to playwright-async April 5, 2026 11:46
@sazid sazid closed this Apr 23, 2026
@sazid sazid reopened this Apr 23, 2026
@riz-hossain
Copy link
Copy Markdown
Contributor

🔎 ZeuZ PR Review

Open the full report in ZeuZ: Review findings and apply suggestions

Overview Value
Agents ✅ 4 completed
Suggestions 💡 18

Agent breakdown

→ General Review

Status: ✅ Completed
Suggestions: 5 suggestions

The PR adds named browser sessions and per-session CDP ports, but the session plumbing is inconsistent and likely incorrect: session state handling duplicates logic in multiple places, relies on globals in a helper, and introduces likely runtime bugs (undefined variables, wrong teardown semantics, and incomplete/possibly broken new utils.py content).

→ Security Review

Status: ✅ Completed
Suggestions: 4 suggestions

The PR adds named dual-driver browser sessions and introduces session switching/teardown plus unique remote-debugging ports. Main security risks are session-name misuse leading to unsafe resource lookup/teardown and potentially unsafe debug-port/CDP handling; there are also robustness issues that can cause cross-session data leakage or unintended teardown.

→ Architecture Review

Status: ✅ Completed
Suggestions: 5 suggestions

High-level: the PR introduces cross-session handling for Playwright/Selenium and attempts to isolate CDP/remote-debug ports per session. However, it adds significant global-state mutation and relies on a new shared-session utility file without fully validating consistency, lifecycle, and parsing semantics—creating long-term fragility and potential runtime errors.

→ Performance Review

Status: ✅ Completed
Suggestions: 4 suggestions

PR introduces per-session browser/session handling but adds multiple hotspots that can become inefficient and error-prone at scale (session parsing repeated per action, expensive list/dict scans during teardown, and repeated get_session/port-hash recomputation). Main performance risk is O(n) scans in hot teardown logic and redundant per-call parsing/derivation.

Open ZeuZ to inspect full findings, continue an agent conversation, or apply safe patch suggestions.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants