Skip to content

[Req-81] Playwright-Selenium Dual-Driver Implementation#670

Open
nasif-z wants to merge 4 commits intoplaywright-asyncfrom
req-81-playwright-selenium-dual-driver
Open

[Req-81] Playwright-Selenium Dual-Driver Implementation#670
nasif-z wants to merge 4 commits intoplaywright-asyncfrom
req-81-playwright-selenium-dual-driver

Conversation

@nasif-z
Copy link
Collaborator

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

Runtime Parameter: BROWSER_DRIVER

  • This runtime parameter can be set to the value of either playwright or selenium
  • Ensures all web actions in the test case will be executed through the chosen driver in this parameter, regardless of what was chosen in the steps
  • Example: test case contains steps all of which use selenium action - BROWSER_DRIVER is set to playwright - all those actions will be converted to playwright action internally by Node at runtime

Optional Parameter: browser driver

This works similarly to the runtime parameter above but this takes the highest priority when both parameters are in place. This is meant to override the driver preference only for certain actions, allowing the user to have fine-grained driver selection for their steps even when using the runtime parameter to set a global driver preference.

  • browser driver | optional parameter | playwright or selenium
  • The above row can be added to any web action and it will convert it to an action of the driver in the parameter
  • Example: if the action is selenium action - and if this optional parameter is set to playwright - the action will be converted to playwright action internally by Node

Seamless driver switching

  • Any browser launched with Selenium will be automatically connected to a Playwright instance in the background
  • Any browser launched with Playwright will be automatically connected to a Selenium instance in the background
  • This allows playwright action to run on Selenium-launched browsers and selenium action to run on Playwright-launched browsers
  • Only works on Chromium-based browsers since it uses Chrome DevTools Protocol (CDP) to establish a remote debugging bridge connection
  • Simplified diagram on how this works:
image

@nasif-z nasif-z requested a review from sazid March 3, 2026 05:50
@nasif-z nasif-z self-assigned this Mar 3, 2026
@nasif-z nasif-z added enhancement New feature or request action-web node-internals feature and removed enhancement New feature or request labels Mar 3, 2026
@sazid
Copy link
Member

sazid commented Mar 7, 2026

@codex review

Copy link

@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: 7bf65e1a4d

ℹ️ 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".

# If runtime parameter is present and valid, update the action subfield
if browser_driver_runtime_parameter and browser_driver_runtime_parameter.strip().lower() in ("playwright", "selenium"):
CommonUtil.ExecLog(sModuleInfo, "Runtime parameter for browser driver preference detected", 5)
updated_action_subfield = browser_driver_runtime_parameter + " action"

Choose a reason for hiding this comment

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

P1 Badge Normalize routed driver name before building action subfield

The routing check accepts BROWSER_DRIVER case-insensitively, but this assignment uses the raw runtime value, so inputs like Playwright or selenium become Playwright action / selenium action and then fail module resolution in get_module_and_function (which matches module tokens exactly). This makes the new runtime override intermittently break based on capitalization/spacing even though the validation path explicitly treats those values as valid.

Useful? React with 👍 / 👎.

page = context.pages[0]

from Framework.Built_In_Automation.Web.Playwright import BuiltInFunctions as PlaywrightBuiltInFunctions
PlaywrightBuiltInFunctions.current_page = page

Choose a reason for hiding this comment

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

P1 Badge Populate Playwright globals when attaching to Selenium session

This bridge only sets PlaywrightBuiltInFunctions.current_page, but does not set Playwright's context/browser globals, so actions that depend on context (for example tab/window operations that explicitly fail when context is None) still break after a Selenium-launched attach. That means the new “seamless switching” path is incomplete for a non-trivial subset of Playwright actions.

Useful? React with 👍 / 👎.

launch_options["args"] = args

# Add remote debugging port for CDP connection
all_args = args + ["--remote-debugging-port=9222"]

Choose a reason for hiding this comment

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

P2 Badge Avoid hard-coding a single CDP port for all browser launches

Using a fixed --remote-debugging-port=9222 for every Playwright launch causes deterministic port collisions when more than one browser instance is opened (for example multiple page_id sessions) or when runs overlap on the same machine, leading to failed launches or attaching to the wrong target. The same constant is also used by the attach path, so this becomes a systemic single-port bottleneck rather than a per-session bridge.

Useful? React with 👍 / 👎.

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.

2 participants