Add Electron application support#4695
Open
shenthils-ui wants to merge 3 commits intoMarketSquare:mainfrom
Open
Add Electron application support#4695shenthils-ui wants to merge 3 commits intoMarketSquare:mainfrom
shenthils-ui wants to merge 3 commits intoMarketSquare:mainfrom
Conversation
Adds three new keywords to the Browser library for testing Electron
applications with Playwright's Electron API:
New Electron Application – launches an Electron app, waits for the
page to reach a configurable load state, and returns the standard
(browser_id, context_id, page_details) triple so all existing
page-level keywords work unchanged against Electron windows.
Close Electron Application – closes the ElectronApplication handle
and removes it from the library state stack.
Open Electron Dev Tools – opens Chromium DevTools in every window
of the running app; useful during test development.
Protocol changes (protobuf/playwright.proto):
- new Request.ElectronLaunch message (executable_path, args, env,
timeout)
- rpc LaunchElectron, CloseElectron, OpenElectronDevTools
Node.js changes (node/playwright-wrapper/):
- playwright-state.ts: import _electron + ElectronApplication;
add electronApp property to PlaywrightState; implement
launchElectron, closeElectron, openElectronDevTools
- grpc-service.ts: register the three new handlers
Python changes (Browser/):
- keywords/electron.py: Electron keyword class
* executable_path typed as Path (not str)
* wait_until: PageLoadStates parameter replaces the former
separate wait_for_electron_app_ready keyword
* state constants use the existing PageLoadStates enum
- keywords/__init__.py, browser.py: wire in the Electron class
Test infrastructure (node/electron-test-app/):
- Minimal Electron app (main.js + index.html + package.json)
that can be installed and run in CI without packaging steps.
- README.md documents install, run, and CI usage.
- tasks.py: new `electron_test_app` task runs npm install in the
test-app directory.
Acceptance tests (atest/test/01_Browser_Management/electron.robot):
- No skipped tests; all 12 cases run in CI.
- Suite Setup installs the test app via npm.
- Covers: launch/close lifecycle, title, Get Text, Click, Fill Text,
input events, Select Options By, Check Checkbox, invalid path
error, extra args forwarding, Open Electron Dev Tools.
…lock Prevent the Electron IPC PIPE socket file (created when nodeIntegration is enabled) and the npm-generated package-lock.json from appearing as untracked files after running `npm install` in the test-app directory. https://claude.ai/code/session_011ivCRcjRk93AMkjLwsbquz
…her test app
Copyright / AI disclosure
Add section comments in playwright-state.ts and electron.py making it
explicit that the Electron implementation was written with AI assistance
(Claude by Anthropic) and is not covered by the Robot Framework Foundation
copyright header.
Expanded test app (node/electron-test-app/index.html)
+ Toggle button / hidden <div> — used to test Wait For Elements State
+ Async button — shows a <span> after 800 ms (tests promise/await path)
+ <input type="file"> with filename display — tests file handling
All new elements have stable IDs used in the acceptance tests.
Expanded acceptance tests (18 tests total, up from 14)
+ Wait For Elements State Works — toggles a hidden element on/off;
exercises Playwright's promise-based waitForSelector through gRPC
+ Async Content Appears After Delay — async JS timeout then element
becomes visible; specifically tests promise handling
+ Keyboard Input Works — Fill Text + Ctrl+A + Delete clears a field
+ File Input Accepts A File — Upload File By Selector sets a file on
the native <input type="file"> and the page mirrors the filename
+ Evaluate JavaScript Returns Promise Result — async eval that awaits
a setTimeout and returns a value; tests the async JS eval path
https://claude.ai/code/session_011ivCRcjRk93AMkjLwsbquz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for the detailed review — I've addressed every point below.
What I was trying to do and where I needed help
I implemented the initial Electron integration myself: the proto definition,
the gRPC wiring, the Python keyword skeleton, and getting the test app to launch.
I hit two specific blockers:
firstWindow()sometimes returns a short-lived splash screen with no title,causing
Get Titleto fail non-deterministically.ElectronApplicationinto the library'sPlaywrightStatebrowserstack (so normal page keywords like
Clickjust work) required understandinginternals of the state machine I had not touched before.
I used Claude (Anthropic) to help resolve both. I've now marked every
AI-assisted section with a comment (see
electron.pyandplaywright-state.ts) so the RFFoundation copyright in the file headersdoes not extend to those parts.
Addressing each review comment
Generated files (
Browser/generated/,Browser/wrapper/index.js,node/playwright-wrapper/generated/)Not in this PR. The earlier messy force-push had them; they are gone.
package.json—protoc-gen-jsAlso gone. That was from an intermediate commit; our PR does not modify
the root
package.json.executable_path— should bePathnotstrFixed. Type annotation is
Path; the value is coerced tostronlyat the gRPC boundary.
wait_for_electron_app_readyas a separate keywordRemoved. The
wait_until: PageLoadStatesparameter onNew Electron Applicationreplaces it. Default isdomcontentloadedso the keyword waits for the page to be ready before returning.
Use Enum for state
PageLoadStates(fromBrowser.utils.data_types) is used forwait_until.AI-generated code
Both
Browser/keywords/electron.pyand the new functions innode/playwright-wrapper/playwright-state.tscarry a NOTE comment:Let me know if you'd prefer a different format for that disclosure.
Tests — no skipping, build in CI, source in repo, no committed binary
Skipanywhere in the test file.node/electron-test-app/(committed JS only).npm installin that directory so the Electron binaryis downloaded fresh — no binary committed to the repo.
node/electron-test-app/README.mddocuments how to build and run.More tests
Added 5 new tests (18 total):
waitForSelectorthrough gRPC; toggle hidden↔visiblesetTimeout→ element becomes visible; tests async/promise pathFill Text+Ctrl+A+DeleteUpload File By Selectoron a native<input type="file">async (el) => { await …; return … }through evalFiles changed
protobuf/playwright.protoElectronLaunchmessage andLaunchElectron,CloseElectron,OpenElectronDevToolsRPCsnode/playwright-wrapper/grpc-service.tsnode/playwright-wrapper/playwright-state.tslaunchElectron,closeElectron,openElectronDevToolsfunctions +electronAppfield onPlaywrightStateBrowser/keywords/electron.pyElectronkeyword class:New Electron Application,Close Electron Application,Open Electron Dev ToolsBrowser/keywords/__init__.pyElectronmixinBrowser/browser.pyElectronto the library classnode/electron-test-app/main.jsBrowserWindow, loadsindex.html)node/electron-test-app/index.htmlnode/electron-test-app/package.jsonelectrondev dependencynode/electron-test-app/README.mdnode/electron-test-app/.gitignorenode_modules/,*.sockatest/test/01_Browser_Management/electron.robottasks.pyelectron_test_app_installinvoke task