Skip to content

Async Action Support: Convert Node internal functions with async/await#657

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

Async Action Support: Convert Node internal functions with async/await#657
nasif-z wants to merge 44 commits into
devfrom
playwright-async

Conversation

@nasif-z
Copy link
Copy Markdown
Collaborator

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

Experimental

This PR is currently meant for experimenting with Playwright Web actions in order to compare its performance with Selenium.

  • Converts several action handling and driver functions from synchronous to async. Thorough testing recommended before merging into dev.
  • Everything runs in the main async event loop, no additional loops are created.
  • All existing synchronous actions continue to work as usual.

Fixed bugs

Fixed a few bugs in the initial Claude-generated code for Playwright web actions, such as:

  • Go to Link action not executing the open browser action automatically in case a browser is not already open
  • Open browser action defaulting to headless mode
  • Partial text match not working in one case

Tested Actions/Functions

  1. Open Browser
  2. Go to Link
  3. Enter Text
  4. Click Element
  5. Locate Element
  6. Wait For Element
  7. Scroll to Element
  8. Save into Variable
  9. If Element Exists [True/False] (Conditional Action)
  10. Switch Iframe
  11. Tear Down Browser

Note

Need to write playwright action in the action name instead of selenium action.

Test Cases used for debugging:

  1. TEST-12438
  2. TEST-12506

@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
Copy link
Copy Markdown
Member

sazid commented Feb 9, 2026

@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 and others added 15 commits March 5, 2026 12:44
Similar to Selenium open browser action
…lenium-dual-driver

[Req-81] Playwright-Selenium Dual-Driver Implementation
Add shared browser session utilities for normalized session parsing, safe registry access, session removal, and available CDP port allocation.

Wire Selenium and Playwright actions through a pre-action session activator so actions with an explicit session parameter run against the requested browser instead of whichever global driver was last active. Missing explicit sessions now fail for non-creation actions.

Keep Selenium and Playwright session registries in sync across open, switch, and teardown paths. Store CDP metadata in browser_sessions, clean up paired CDP resources, and preserve non-targeted sessions during framework-specific teardown.

Make Playwright frame state session-aware, fix several Playwright actions that were calling async APIs synchronously, collect browser logs across session Selenium drivers, and make screenshots prefer the active Playwright page when appropriate.

Add focused browser session unit tests for session activation, missing-session failure, and session registry removal.
…ssions

[Task-2247] Named Browser Sessions For Dual-Driver Browser Instances
@Antu7
Copy link
Copy Markdown
Collaborator

Antu7 commented May 19, 2026

🔎 ZeuZ PR Review

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

Overview Value
Agents ❌ 4 failed
Suggestions 💡 0

Agent breakdown

→ General Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe237edae9120ba-IAD, request id: req_efa80c35f80548e287c43404fa21011e

→ Security Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe237ec59458a7d-IAD, request id: req_e7bc6115793a4fb08308fc2592b55220

→ Performance Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe237ec8b4698e4-IAD, request id: req_c03a5dfa02434249a846406619c3c559

→ Testing Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe237edba9a4f8b-IAD, request id: req_93b41cd2376741c29e760b3902d32360

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

@Antu7
Copy link
Copy Markdown
Collaborator

Antu7 commented May 19, 2026

🔎 ZeuZ PR Review

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

Overview Value
Agents ❌ 4 failed
Suggestions 💡 0

Agent breakdown

→ General Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe23ee1a9fbb4ba-IAD, request id: req_afc05401a0a44101bbca1098a863a5c6

→ Security Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe23ee08bdce643-IAD, request id: req_321b63cd3ea946e0b2d173756201b0fd

→ Performance Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe23ee18e0f0829-IAD, request id: req_5468cafca8a544fbaf6aca722e1a4682

→ Testing Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe23edf9a295764-IAD, request id: req_09f2617be49e4ae9bbec7ff96c24349b

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

Run Playwright teardown before Selenium during driver cleanup so Playwright-owned sessions close their async browser resources first.

Teach Selenium global teardown to skip sessions that are owned by Playwright, while still allowing Selenium-owned sessions with Playwright bridges to be cleaned up.

Add a regression test covering Playwright-owned sessions with Selenium CDP bridges so Selenium teardown does not close or remove them.
@Antu7
Copy link
Copy Markdown
Collaborator

Antu7 commented May 19, 2026

🔎 ZeuZ PR Review

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

Overview Value
Agents ⏳ 1 reviewing, ❌ 3 failed
Suggestions 💡 0

Agent breakdown

→ General Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe300c33da5fc33-IAD, request id: req_4280a832f3a648139c8338d9f4f14b9e

→ Security Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe300c2af85ae0c-IAD, request id: req_eae8425f71ba414999888fa90528b84d

→ Performance Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe300c2eafed680-IAD, request id: req_66f0c9e11db44596adc47ad4a20de9b3

→ Testing Review

Status: ⏳ Reviewing
Suggestions: 0 suggestions

Current status: reviewing.

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

Treat index rows in Playwright switch_iframe as iframe/frame indexes instead of generic element attributes. This prevents index iframe parameters from producing invalid selectors such as [index='1'].

Allow a default-content reset and a subsequent iframe target in the same action, matching the Selenium action behavior used by existing test data.

Build indexed frame locators with frame_locator(tag).nth(index), preserve selector-based iframe targets, and save the resulting frame locator back to the active browser session.

Add regression coverage for switching to default content and then selecting iframe index 1 with a Playwright action.
@Antu7
Copy link
Copy Markdown
Collaborator

Antu7 commented May 19, 2026

🔎 ZeuZ PR Review

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

Overview Value
Agents ❌ 4 failed
Suggestions 💡 0

Agent breakdown

→ General Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe37f2eba91576d-IAD, request id: req_6879152d08754483831ae09717478a89

→ Security Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe37f30ae3f37c5-IAD, request id: req_45a7c6c2e9204c72825d483dc6dd0d3b

→ Performance Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe37f3139e6a13a-IAD, request id: req_d084e14d0fd44bed97d05bde335be580

→ Testing Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9fe37f2d8f4d1734-IAD, request id: req_1d7e27c585444396b7f5e03c370b0441

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

@Antu7
Copy link
Copy Markdown
Collaborator

Antu7 commented May 20, 2026

🔎 ZeuZ PR Review

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

Overview Value
Agents ❌ 4 failed
Suggestions 💡 0

Agent breakdown

→ General Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9feafde92d0d2959-IAD, request id: req_2a226ff031b7460eb195cb938bfcba12

→ Security Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9feafde91b697100-IAD, request id: req_81d6d325a751411fbee441eb40135489

→ Performance Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9feafdea683fc9fe-IAD, request id: req_2cf11bb2d9584cff88baf8a334c84144

→ Testing Review

Status: ❌ Failed
Suggestions: 0 suggestions

unexpected status 401 Unauthorized: Incorrect API key provided: sk-proj-********************************************DpoS. You can find your API key at https://platform.openai.com/account/api-keys., url: https://api.openai.com/v1/responses, cf-ray: 9feafdec4f0e5e59-IAD, request id: req_cc10e6e8f9e74d39b36e387d72170cc6

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

- Defaults to viewport instead of full page
- Default image quality is now 70%
- Skips `PIL` post-processing for Playwright
@Antu7
Copy link
Copy Markdown
Collaborator

Antu7 commented May 20, 2026

🔎 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 introduces two high-severity regressions: one loop helper still calls Run_Sequential_Actions() without awaiting it, and the bypass-path still invokes the now-async Action_Handler() synchronously. Both will surface as coroutine objects instead of real results and break execution flow.

→ Security Review

Status: ✅ Completed
Suggestions: 0 suggestions

No security-relevant issues were introduced by this async Playwright refactor in the reviewed diff.

→ Performance Review

Status: ✅ Completed
Suggestions: 1 suggestion

I found one meaningful performance risk: the new Playwright startup path now also launches a Selenium ChromeDriver for every browser session, which adds extra process startup and duplicate browser-control overhead on the hot path.

→ Testing Review

Status: ✅ Completed
Suggestions: 2 suggestions

The PR adds substantial async Playwright/session-routing behavior, but I don’t see corresponding tests covering the new control flow or regression points.

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

@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
Copy link
Copy Markdown
Collaborator

Antu7 commented May 24, 2026

🔎 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.

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