Skip to content

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

Open
nasif-z wants to merge 58 commits into
devfrom
playwright-async
Open

Playwright Async Actions with Selenium Actions Parity and Browser Session Interoperability#657
nasif-z wants to merge 58 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.
  • Expands Playwright action coverage and parity with Selenium, including locator behavior, conditional actions, iframe context support, and hydration of 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 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.
  • Patched Playwright wait-for-element behavior with a sleep-based stabilization step where needed.
  • 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.
  • Completed browser session action support across the routed driver/action stack.
  • 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.

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.
  • Added missing locator logic in Playwright so locator resolution matches Selenium Get_Element behavior more closely.
  • 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.
  • Replaced Playwright auto browser download behavior with the Selenium Chrome for Testing functions where appropriate during the branch history, followed later by the Playwright-integrated installation path.
  • 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.
  • 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 Playwright locator regression tests in tests/test_playwright_locator.py.

Files With Significant Changes

  • Framework/Built_In_Automation/Web/Playwright/BuiltInFunctions.py
  • Framework/Built_In_Automation/Web/Playwright/locator.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/sequential_actions.py
  • Framework/Built_In_Automation/Sequential_Actions/common_functions.py
  • Framework/MainDriverApi.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
nasif-z added 2 commits May 20, 2026 17:26
- Defaults to viewport instead of full page
- Default image quality is now 70%
- Skips `PIL` post-processing for Playwright
@Antu7

This comment was marked as outdated.

@Antu7 Antu7 requested a review from ToWhiD073 May 20, 2026 14:41
Avoid starting Playwright during Selenium browser launches and avoid creating Selenium CDP drivers during Playwright launches.

Store session metadata with the remote debugging port and attach the opposite framework only when an action from that framework targets the session.
@Antu7

Antu7 commented May 24, 2026

Copy link
Copy Markdown
Collaborator

🔎 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 conversion is a good direction, but a few synchronous call sites were left behind and will now return coroutine objects instead of running browser actions. There is also a risky default behavior change in Playwright browser startup.

→ Security Review

Status: ✅ Completed
Suggestions: 0 suggestions

No clear security regressions are introduced in the provided PR diff. The changes primarily refactor execution to async/await and add Playwright session routing without exposing a direct injection, auth, or secret-handling issue visible in the diff.

→ Performance Review

Status: ✅ Completed
Suggestions: 0 suggestions

No performance regressions or scalability issues stood out in this PR diff. The changes are mostly async plumbing plus Playwright session routing, with no clear N+1, unbounded query, or memory-growth concerns visible from the code provided.

→ Testing Review

Status: ✅ Completed
Suggestions: 1 suggestion

The PR adds substantial async/session-routing behavior in the browser automation path, but the test suite only covers a small slice of the new Playwright session helpers. The highest-risk regressions are currently unprotected by tests.

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

nasif-z and others added 6 commits June 7, 2026 20:25
- Matches Selenium's `Get_Element` behaviour
* new actions added

* clean code added

* test case fixes

* update on previous actions & new action open electron app added

* bug fixes

---------

Co-authored-by: Nazmul Ahsan <nazmulahsan@Nazmuls-MacBook-Pro.local>
Co-authored-by: Nasif <nasifcodes@gmail.com>
- Add missing Playwright action declarations and implementations

- Align Playwright action parsing with Selenium step data formats

- Improve locator shadow DOM parity and regression coverage

- Add focused Playwright parity tests
- Add shared browser compatibility hydration before execute-python snippets run
- Lazily bridge Selenium and Playwright sessions using existing CDP attachment paths
- Support top-level await for async Playwright custom code while preserving sync snippets
- Read the running Playwright Chromium version from the CDP version endpoint
- Prefer ZeuZ Chrome-for-Testing cached chromedriver before downloading with webdriver-manager
- Attach Selenium with a matching ChromeDriver to avoid browser-version mismatch failures
@AutomationSolutionz AutomationSolutionz deleted a comment from Antu7 Jun 7, 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 💡 5

Agent breakdown

→ General Review

Status: ✅ Completed
Suggestions: 2 suggestions

The async conversion is mostly consistent, but two remaining synchronous call sites will break control flow: one loop helper still treats Run_Sequential_Actions() like a regular function, and the bypass path still calls Action_Handler() without awaiting it. Both can yield coroutine objects instead of execution results, causing loops/bypass logic to misbehave.

→ Security Review

Status: ✅ Completed
Suggestions: 0 suggestions

No high-confidence security issues in the PR diff. The changes are primarily async refactors and Playwright session-routing additions, with no clear new injection, authz, or secret-handling flaws introduced.

→ Performance Review

Status: ✅ Completed
Suggestions: 1 suggestion

I found one significant performance risk in the new Playwright network logging path: captured requests are kept entirely in memory with no bound, and optional response-body capture can amplify memory use quickly on long or chatty pages.

→ Testing Review

Status: ✅ Completed
Suggestions: 2 suggestions

The PR makes core dispatcher and Playwright execution paths async, but there are no regression tests covering those new control flows. I found the existing Playwright/session tests helpful, but they stop short of asserting the async dispatcher, browser-driver routing, and top-level-await Python execution behavior introduced here.

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

@AutomationSolutionz AutomationSolutionz deleted a comment from Antu7 Jun 7, 2026
@AutomationSolutionz AutomationSolutionz deleted a comment from Antu7 Jun 7, 2026
@AutomationSolutionz AutomationSolutionz deleted a comment from Antu7 Jun 7, 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.

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.

5 participants