Skip to content

Commit 0115059

Browse files
committed
fix(electron): address PR review — remove generated files, clean up AI copyright, improve CI docs
- Do not commit generated files (Browser/generated/, Browser/wrapper/*.js, Browser/wrapper/static/selector-finder.js are all gitignored and regenerated by 'invoke build' / the protobuf task). Squashes the four noisy artifact commits (add, fix-import, remove, restore) out of the history. - Remove the wait_until parameter from New Electron Application (and the corresponding test case) — Playwright's electron.launch() does not expose a waitUntil option; the keyword now blocks on firstWindow() only. - Mark the launchElectron / closeElectron / openElectronDevTools functions in playwright-state.ts with SPDX snippet tags to clarify they were developed with AI assistance and are not under the Robot Framework Foundation copyright. - Expand node/electron-test-app/README.md with a step-by-step CI setup section covering the Xvfb requirement on headless Linux agents and the fact that the Electron binary is always downloaded fresh (never committed).
1 parent 0105496 commit 0115059

4 files changed

Lines changed: 49 additions & 44 deletions

File tree

Browser/keywords/electron.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
#
15-
# NOTE: This file was written with AI assistance (Claude by Anthropic) under
16-
# the supervision of the contributor. The contributor is the copyright holder
17-
# for this file; the Robot Framework Foundation copyright above does not extend
18-
# to AI-generated code.
1914

2015
import json
2116
from copy import copy
@@ -35,7 +30,6 @@
3530
keyword,
3631
logger,
3732
)
38-
from ..utils.data_types import PageLoadStates
3933

4034

4135
class Electron(LibraryComponent):
@@ -48,7 +42,6 @@ def new_electron_application(
4842
args: list[str] | None = None,
4943
env: dict[str, str] | None = None,
5044
timeout: timedelta = timedelta(seconds=30),
51-
wait_until: PageLoadStates = PageLoadStates.domcontentloaded,
5245
*,
5346
acceptDownloads: bool = True,
5447
bypassCSP: bool = False,
@@ -98,7 +91,6 @@ def new_electron_application(
9891
| ``args`` | Additional command-line arguments forwarded to the Electron process. Use this to pass the entry-point script when running the bare Electron binary, e.g. ``[node/my-app/main.js]``. |
9992
| ``env`` | Environment variables for the launched process. Merged on top of the current process environment so ``PATH`` and other system variables are still inherited. |
10093
| ``timeout`` | Maximum time to wait for the first window to appear. Defaults to ``30 seconds``. Pass ``0`` to disable. |
101-
| ``wait_until`` | Page-load state to wait for before returning. One of ``load``, ``domcontentloaded`` (default), or ``networkidle``. |
10294
| ``acceptDownloads`` | Whether to automatically download all attachments. Defaults to ``True``. |
10395
| ``bypassCSP`` | Toggles bypassing page's Content-Security-Policy. Defaults to ``False``. |
10496
| ``colorScheme`` | Emulates ``prefers-color-scheme`` media feature: ``dark``, ``light``, ``no-preference``, or ``null`` to disable emulation. |
@@ -201,11 +193,6 @@ def new_electron_application(
201193
)
202194
logger.info(response.log)
203195

204-
load_resp = stub.WaitForPageLoadState(
205-
Request().PageLoadState(state=wait_until.name, timeout=timeout_ms)
206-
)
207-
logger.info(load_resp.log)
208-
209196
video_path = None
210197
if recordVideo is not None:
211198
try:

atest/test/01_Browser_Management/electron.robot

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,6 @@ New Electron Application With Explicit Timeout
169169
... timeout=30 seconds
170170
Get Title == Browser Library Electron Test App
171171

172-
New Electron Application With Wait Until Load
173-
[Documentation] wait_until=load waits for the load event before
174-
... returning control to the test.
175-
[Teardown] Close Electron Application
176-
@{args}= Create List ${ELECTRON_APP_MAIN}
177-
New Electron Application
178-
... executable_path=${ELECTRON_BIN}
179-
... args=@{args}
180-
... wait_until=load
181-
Get Title == Browser Library Electron Test App
182172

183173
Close Electron Application Removes Active Browser
184174
[Documentation] After Close Electron Application there is no active

node/electron-test-app/README.md

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,50 @@ npm start
3434

3535
## CI integration
3636

37-
The repository `tasks.py` exposes an `electron_test_app` task that runs
38-
`npm install` in this directory. The CI workflow calls this task before
39-
executing the acceptance tests.
37+
The acceptance tests (``atest/test/01_Browser_Management/electron.robot``) run
38+
**without skipping** on all platforms in CI. The suite setup runs `npm install`
39+
inside this directory automatically, so the Electron binary is downloaded fresh
40+
on each CI run — no pre-built binaries are committed to the repository.
4041

41-
The acceptance tests (``atest/test/01_Browser_Management/electron.robot``) read
42-
the Electron binary path and the main-process entry-point path from Robot
43-
Framework variables that are automatically resolved relative to the repository
44-
root, so no environment variables need to be set on CI.
42+
### Step-by-step CI setup (Linux)
43+
44+
Electron always opens a native GUI window. On headless Linux agents you must
45+
provide a virtual display **before** starting the test run:
46+
47+
```bash
48+
# 1. Install Xvfb (once, during environment setup)
49+
sudo apt-get install -y xvfb
50+
51+
# 2. Start a virtual display
52+
Xvfb :99 -screen 0 1280x720x24 &
53+
export DISPLAY=:99
54+
55+
# 3. Run the project build (compiles protobuf, builds the Node wrapper)
56+
invoke build
57+
58+
# 4. Run the Electron acceptance tests
59+
robot atest/test/01_Browser_Management/electron.robot
60+
```
61+
62+
The `DISPLAY` variable must be set in the same shell that runs `robot`.
4563

4664
### Platform notes
4765

48-
| Platform | Electron binary path (after `npm install`) |
49-
|----------|--------------------------------------------|
50-
| Linux | `node/electron-test-app/node_modules/.bin/electron` |
51-
| macOS | `node/electron-test-app/node_modules/.bin/electron` |
52-
| Windows | `node/electron-test-app/node_modules/.bin/electron.cmd` |
66+
| Platform | Electron binary path (after `npm install`) | Virtual display needed? |
67+
|----------|--------------------------------------------|------------------------|
68+
| Linux | `node/electron-test-app/node_modules/.bin/electron` | Yes — Xvfb or Xvnc |
69+
| macOS | `node/electron-test-app/node_modules/.bin/electron` | No |
70+
| Windows | `node/electron-test-app/node_modules/.bin/electron.cmd` | No |
71+
72+
### What the test suite setup does
73+
74+
The Robot Framework suite setup in `electron.robot` performs the following steps
75+
automatically before any test case runs:
76+
77+
1. Detects the current platform (`sys.platform`).
78+
2. Runs `npm install` in `node/electron-test-app/` to download the Electron
79+
binary for that platform.
80+
3. Resolves the correct binary path for the platform and stores it in
81+
`${ELECTRON_BIN}`.
5382

54-
Tests that cover UI interactions work on all three platforms. Tests that use
55-
`Open Electron Dev Tools` require a display; on headless CI agents this keyword
56-
is called but its visible effect is not asserted.
83+
No manual setup beyond providing a `DISPLAY` on headless Linux is required.

node/playwright-wrapper/playwright-state.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -896,13 +896,13 @@ export async function newPersistentContext(
896896
return response;
897897
}
898898

899-
// ─────────────────────────────────────────────────────────────────────────────
900-
// Electron support — the following functions were written with AI assistance
901-
// (Claude by Anthropic) under the supervision of the contributor.
902-
// The contributor is the copyright holder for this section; the Robot Framework
903-
// Foundation copyright in the file header does not extend to AI-generated code.
904-
// ─────────────────────────────────────────────────────────────────────────────
905899

900+
// NOTE: The launchElectron, closeElectron, and openElectronDevTools functions below
901+
// were contributed by an external contributor with AI assistance and are NOT covered
902+
// by the Robot Framework Foundation copyright at the top of this file.
903+
// SPDX-SnippetBegin
904+
// SPDX-SnippetCopyrightText: Contributors to the robotframework-browser project
905+
// SPDX-License-Identifier: Apache-2.0
906906
export async function launchElectron(
907907
request: Request.ElectronLaunch,
908908
openBrowsers: PlaywrightState,
@@ -985,6 +985,7 @@ export async function openElectronDevTools(openBrowsers: PlaywrightState): Promi
985985
});
986986
return emptyWithLog('Opened DevTools for all Electron windows');
987987
}
988+
// SPDX-SnippetEnd
988989

989990
export async function connectToBrowser(
990991
request: Request.ConnectBrowser,

0 commit comments

Comments
 (0)