Skip to content

Playwright Async Actions with Selenium Actions Parity and Browser Session Interoperability#657

Merged
nasif-z merged 64 commits into
devfrom
playwright-async
Jul 1, 2026
Merged

Playwright Async Actions with Selenium Actions Parity and Browser Session Interoperability#657
nasif-z merged 64 commits into
devfrom
playwright-async

Conversation

@nasif-z

@nasif-z nasif-z commented Feb 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Converts the Playwright execution path from sync-style handling to async across core action handlers, browser actions, screenshot capture, teardown, and MainDriver integration.
  • Adds cross-framework browser session support so Playwright and Selenium can create, reuse, attach to, validate, and tear down shared browser sessions.
  • Routes Playwright element lookup through shared LocateElement.Get_Element parsing and query construction instead of a separate Playwright locator module.
  • Expands Playwright action coverage and parity with Selenium, including conditional actions, iframe context support, parent-scoped lookup, Shadow DOM lookup, and hydrated browser globals for custom code.
  • Fixes multiple Playwright behavior issues around drag and drop, partial text validation, save attribute value handling, iframe switching, cleanup ordering, and action parsing.
  • Adds browser bootstrap and attachment improvements, including optional browser driver parameters, CDP port hashing, Chromium installation/download handling, and Chrome/ChromeDriver matching during session attachment.
  • Adds regression coverage for browser sessions, Playwright action parity, and shared Playwright locator behavior.

Playwright Async Migration

  • Converted Playwright action handlers and MainDriver integration to async execution.
  • Converted the Playwright go to link action to async and reset iframe context during navigation.
  • Converted Playwright teardown flow to async and fixed teardown/cleanup ordering.
  • Converted screenshot capture to async, removing the threaded screenshot path.
  • Updated Playwright web actions broadly to work with the Playwright Async API.

Browser Session Interoperability

  • Added shared browser session utility functions and common browser session support used by both Playwright and Selenium.
  • Added session creation during Playwright open browser and Selenium open browser flows.
  • Added session existence checks to Playwright and Selenium go to link and other commonly used actions.
  • Added session-aware teardown behavior for browser actions.
  • Added lazy attach behavior for cross-browser automation sessions.
  • Added automatic connection from Playwright to Selenium browser sessions.
  • Added automatic connection from Selenium to Playwright browser sessions.
  • Populated Playwright globals when attaching to Selenium sessions.
  • Hydrated browser globals for custom Python code when running with attached browser sessions.
  • Resolved existing Selenium drivers by driver_id instead of assuming the default session.
  • Kept parsing of Playwright driver IDs from input parameters during session attachment flows.
  • Normalized routed driver names before building action subfields.

Shared Locator Support

  • Added Playwright detection to LocateElement.Get_Element while keeping Selenium, Appium, XML, and desktop behavior synchronous.
  • Reused shared LocateElement parsing for index, allow hidden, save parameter, get parameter, Shadow DOM rows, raw XPath/CSS, and relationship rows.
  • Reused shared query construction through _construct_query, _construct_xpath_list, _locate_index_number, build_css_selector_query, text_filter, and shadow_root_elements.
  • Added Playwright execution branches only where the browser API differs: locator, filter(visible=True), wait_for, all, count, text_content, and Shadow DOM locator chaining.
  • Preserved lazy Playwright locator returns for normal action rows while resolving conditional, indexed, text-filtered, and return_all_elements lookups.
  • Removed Framework/Built_In_Automation/Web/Playwright/locator.py and updated Playwright actions to import shared LocateElement as PlaywrightLocator.
  • Updated sequential Playwright conditional lookup to use shared LocateElement.Get_Element.

Playwright Feature Coverage And Parity

  • Added Playwright conditional action handler support.
  • Added iframe context switching support across Playwright actions, then fixed iframe index switching behavior.
  • Improved Playwright/Selenium action parity and matched action column parsing behavior between frameworks.
  • Added support for browser driver as an optional parameter and BROWSER_DRIVER as a runtime parameter.
  • Added Playwright new actions and supporting action declarations.

Reliability Fixes

  • Fixed Playwright drag-and-drop behavior and corrected step data passed into element locator resolution.
  • Fixed a partial text matching bug where validate partial text was not being resolved correctly.
  • Fixed incorrect logic in the Save Attribute Value action.
  • Guarded against missing remote debugging ports during CDP connection.
  • Matched ChromeDriver selection when attaching Selenium to Playwright-driven Chrome sessions.

Browser Provisioning And Installation

  • Added automatic Chromium detection/downloading for Playwright browser path handling.
  • Replaced the earlier custom Chrome installation/download approach with Playwright-integrated Chromium installation.
  • Added CDP port hashing in the Playwright open browser action, matching the Selenium open browser approach.

Performance And Maintenance

  • Optimized Playwright screenshots by defaulting to viewport captures instead of full-page captures.
  • Reduced default Playwright screenshot image quality to 70%.
  • Skipped PIL post-processing for Playwright screenshots.
  • Reduced locator maintenance cost by deleting the duplicated Playwright locator API and keeping shared behavior in LocateElement.py.
  • Added type checking fixes and updated lockfile/dependency state in uv.lock.

Tests

  • Added browser session regression tests in tests/test_browser_sessions.py.
  • Added Playwright action parity regression tests in tests/test_playwright_actions_parity.py.
  • Added shared Playwright locator regression tests in tests/test_playwright_locator.py.
  • Verified today with PYTHONPATH=. pytest tests/test_playwright_locator.py tests/test_playwright_actions_parity.py.
  • Verified today with python -m compileall Framework/Built_In_Automation/Shared_Resources/LocateElement.py Framework/Built_In_Automation/Web/Playwright/BuiltInFunctions.py Framework/Built_In_Automation/Sequential_Actions/sequential_actions.py.

Files With Significant Changes

  • Framework/Built_In_Automation/Shared_Resources/LocateElement.py
  • Framework/Built_In_Automation/Web/Playwright/BuiltInFunctions.py
  • Framework/Built_In_Automation/Sequential_Actions/sequential_actions.py
  • Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py
  • Framework/Built_In_Automation/Web/utils.py
  • Framework/Built_In_Automation/Web/Playwright/utils.py
  • Framework/Built_In_Automation/Sequential_Actions/common_functions.py
  • Framework/MainDriverApi.py
  • tests/test_playwright_locator.py
  • tests/test_playwright_actions_parity.py

@nasif-z nasif-z self-assigned this Feb 9, 2026
@nasif-z nasif-z added bug Something isn't working action-web do-not-merge labels Feb 9, 2026
@nasif-z nasif-z changed the title Playwright Web Actions Async Action Support: Convert Node internal functions with async/await Feb 9, 2026
@sazid

sazid commented Feb 9, 2026

Copy link
Copy Markdown
Member

@claude Review the changes and suggest additional improvements - specially in regards to if something was missed with async/await.

@nasif-z nasif-z removed the bug Something isn't working label Mar 3, 2026
@AutomationSolutionz AutomationSolutionz deleted a comment from Antu7 Jun 7, 2026
@nasif-z nasif-z changed the title Async Action Support: Convert Node internal functions with async/await Playwright Async Actions with Selenium Actions Parity and Browser Session Interoperability Jun 8, 2026
- Await coroutine functions inside the logger decorator before logging exit.

- Preserve existing sync logger behavior and custom fail message logging.

- Add tests covering async log order, sync behavior, and fail messages.
@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 💡 3

Agent breakdown

→ General Review

Status: ✅ Completed
Suggestions: 2 suggestions

The async refactor introduces a high-severity regression in loop execution, and there is another async callsite still invoking the sequential engine synchronously.

→ Security Review

Status: ✅ Completed
Suggestions: 0 suggestions

No critical security regressions stand out in the PR diff. The changes are primarily async refactors and Playwright/Selenium interoperability enhancements, with no obvious new injection, authz, secret-handling, or path-traversal issues introduced.

→ Performance Review

Status: ✅ Completed
Suggestions: 0 suggestions

No significant performance regressions or scalability issues stood out in the PR diff.

→ Testing Review

Status: ✅ Completed
Suggestions: 1 suggestion

The PR changes the core async action dispatcher and Playwright/Selenium interoperability, but there are no added tests covering those new execution paths. That leaves the highest-risk behavior unverified, especially the async Sequential_Actions/Action_Handler flow, top-level execute_python_code await support, and browser-session routing logic.

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

nasif-z added 2 commits June 9, 2026 09:20
- add lazy Get_Element resolution with timeout helper

- pass wait values into high-frequency Playwright actions

- avoid double wait in Wait_For_Element

- cover lazy and resolved locator/action parity paths
- Await sequential loop and bypass handler execution
- Run async sequential callbacks inside performance worker threads
- Await Playwright page/session activation helpers
- Execute async driver functions correctly in threaded runs
- Await coroutine results returned by installer wrapper callables
- Share sync session cleanup for CLI prompt path
@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 💡 6

Agent breakdown

→ General Review

Status: ✅ Completed
Suggestions: 2 suggestions

I found one concrete regression in the new Playwright session routing and one broader API break from making the sequential runner async without updating all direct callers.

→ Security Review

Status: ✅ Completed
Suggestions: 0 suggestions

No high-signal security regressions found in the PR diff. The changes mainly refactor Playwright/Selenium orchestration to async and add new browser actions without introducing an obvious injection, authz, or secret-handling flaw.

→ Performance Review

Status: ✅ Completed
Suggestions: 1 suggestion

One performance risk: the new Playwright network logger buffers every matching request/response in memory until stop, which can grow without bound on busy pages.

→ Testing Review

Status: ✅ Completed
Suggestions: 3 suggestions

The PR adds substantial async dispatch and Playwright routing behavior, but I don’t see tests covering the new execution paths or the browser-driver precedence rules.

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

nasif-z added 5 commits June 9, 2026 14:48
- Normalize legacy wait aliases after browser-driver routing selects Playwright
- Parse legacy wait and wait disable rows in Playwright wait handling
- Cover Playwright versus Selenium routing and legacy timeout/state parsing
- It did not match the Selenium counterpart behaviour
- Selenium's double click action actually does a mouse movement for execution
@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 💡 5

Agent breakdown

→ General Review

Status: ✅ Completed
Suggestions: 2 suggestions

The async migration introduced two blocking regressions in the performance-action path: newly async handlers are still called synchronously, and the handlers themselves still use asyncio.run() inside the async execution chain.

→ Security Review

Status: ✅ Completed
Suggestions: 1 suggestion

No critical security regressions stood out in the async Playwright/Selenium parity changes. I found one data-exposure concern in the new network logging path.

→ Performance Review

Status: ✅ Completed
Suggestions: 1 suggestion

I found one performance issue in the new Playwright network logging path: it retains request objects unnecessarily during capture, which can grow memory usage without affecting the final output.

→ Testing Review

Status: ✅ Completed
Suggestions: 1 suggestion

The PR’s async browser-session routing changes are largely untested; the highest-risk gap is a missing regression test that proves Action_Handler activates the selected Playwright session before dispatching the action.

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

nasif-z added 2 commits June 15, 2026 18:34
…up with `resolve=False`

Actions: keystrokes, validation text reads, save/get element info, scroll, scroll-to-element, change attribute, select/deselect, check/uncheck, and slider
- Uses Playwright's native CSS locator where possible
- Falls back to Selenium-style element locator when needed
@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 💡 5

Agent breakdown

→ General Review

Status: ✅ Completed
Suggestions: 1 suggestion

The async conversion is broadly in the right direction, but there is a runtime blocker in the performance action path: it now calls asyncio.run() from inside the already-running sequential-actions event loop, which will fail as soon as a performance action executes. I didn’t find any other high-signal correctness issues in the diff.

→ Security Review

Status: ✅ Completed
Suggestions: 1 suggestion

I found one moderate data-exposure regression: the new Playwright network-log action collects and persists raw response bodies and request metadata without any redaction or sensitivity filtering.

→ Performance Review

Status: ✅ Completed
Suggestions: 1 suggestion

Found one performance concern in the new async execution path: it repeatedly creates fresh event loops in hot paths, which adds overhead and can become costly under load.

→ Testing Review

Status: ✅ Completed
Suggestions: 2 suggestions

The PR adds several high-risk async execution and Playwright-routing paths, but the new behavior is only partially covered; the biggest gap is regression coverage for async Python execution and browser-driver routing precedence.

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

@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 💡 5

Agent breakdown

→ General Review

Status: ✅ Completed
Suggestions: 1 suggestion

The async migration is broadly consistent, but the new performance-action bridge will fail at runtime because it nests asyncio.run() inside the already-running async sequential executor.

→ Security Review

Status: ✅ Completed
Suggestions: 0 suggestions

No clear security regressions in the PR diff. The changes are mostly async plumbing and Playwright feature additions, with no obvious new injection, authz, or secret-handling issues in the reviewed paths.

→ Performance Review

Status: ✅ Completed
Suggestions: 2 suggestions

The async refactor is functionally broad, but I only see a couple of performance concerns: one benchmark-path overhead from per-task event-loop creation, and one new always-on compatibility hydration step in Python execution.

→ Testing Review

Status: ✅ Completed
Suggestions: 2 suggestions

The PR updates core action dispatching and Playwright routing, but the test suite only covers a subset of the new async and browser-session behavior. The most important gaps are regression coverage for async Python execution and the new Playwright conditional-action path.

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

nasif-z added 2 commits July 1, 2026 20:15
- Route Playwright Page, Locator, and FrameLocator lookups through shared LocateElement parsing and query construction.

- Fold Playwright execution into existing locator, text filter, shadow DOM, index, and result-selection paths.

- Remove the separate Web/Playwright/locator.py helper API and update Playwright actions to use shared LocateElement.Get_Element.

- Preserve lazy locator returns for normal Playwright action rows while resolving conditionals, indexes, text filters, and return_all_elements lookups.

- Update sequential Playwright conditional lookup to use shared LocateElement.

- Refresh Playwright locator and action parity tests for the shared API.

- Verified with PYTHONPATH=. pytest tests/test_playwright_locator.py tests/test_playwright_actions_parity.py and compileall checks.
@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 💡 7

Agent breakdown

→ General Review

Status: ✅ Completed
Suggestions: 2 suggestions

The async conversion is directionally correct, but one new execution path will fail at runtime because it nests asyncio.run() inside the already-async sequential action flow. I found one high-signal correctness issue and no other changes as critical as that in the provided diff.

→ Security Review

Status: ✅ Completed
Suggestions: 0 suggestions

No security findings in the PR diff. The changes primarily convert sequential execution to async and add Playwright/Selenium interoperability without introducing a clear injection, authz, secrets, or data-exposure issue.

→ Performance Review

Status: ✅ Completed
Suggestions: 2 suggestions

Two hotspots stand out in the async conversion: per-task event-loop creation in the load-testing path, and unconditional browser-session hydration before every custom Python execution. Both are likely to add avoidable overhead at scale.

→ Testing Review

Status: ✅ Completed
Suggestions: 3 suggestions

The async conversion and new Playwright routing paths are mostly untested. I found a critical gap in core runner coverage plus missing smoke coverage for the newly declared Playwright actions.

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

@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 💡 5

Agent breakdown

→ General Review

Status: ✅ Completed
Suggestions: 2 suggestions

The async Playwright/Selenium conversion is mostly coherent, but I found two correctness regressions: a legacy Playwright alias now changes behavior, and the new async Sequential_Actions API leaves existing synchronous callers broken.

→ Security Review

Status: ✅ Completed
Suggestions: 0 suggestions

No security-impacting regressions were introduced in this PR diff. The changes are primarily async plumbing and Playwright action routing, with no clear new injection, authz, secrets, or exposure issues in the reviewed patch.

→ Performance Review

Status: ✅ Completed
Suggestions: 1 suggestion

One performance regression stood out: the new async execution path still uses blocking sleeps inside Action_Handler, which can stall the event loop and negate the concurrency benefits of the PR.

→ Testing Review

Status: ✅ Completed
Suggestions: 2 suggestions

The PR expands async sequential execution and adds several new Playwright action routes, but the existing test suite does not cover the new dispatch/routing behavior or the newly registered actions.

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

@nasif-z

nasif-z commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: 5db2c85858

ℹ️ 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 node_cli.py
Comment thread Framework/Utilities/CommonUtil.py
@nasif-z nasif-z merged commit 2d05c5b into dev Jul 1, 2026
7 checks passed
@nasif-z nasif-z deleted the playwright-async branch July 1, 2026 17:26
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.

6 participants