Comments (10)
"We want to make this transition as painless for you as possible" - transition to, any recommendations?
from spectron.
The WebdriverIO community has build a service for WebdriverIO to seamlessly run Electron UI tests in parallel and with all the features WebdriverIO provides. You can find the instructions here. Thanks to @goosewobbler for making this happen!
from spectron.
@suwi transition to "playwright" I guess, see details in #896.
from spectron.
"We want to make this transition as painless for you as possible" - transition to, any recommendations?
Check Playwright doc for Electron support.
I tried Playwright by created a minimal Playwright E2E Testing Sample with CI/CT based on GitHub Actions for Electron App and it seems to work better with the latest electron.
from spectron.
My feedback:
-
Cypress doesn't support Electron anymore, so sadly not an option here. Playwright seems more appropriate, but I've seen test tools come and go in the Electron ecosystem for years...
-
Not 100% sure, but
"preinstall": "export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 || set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1"
seems to help avoiding to install unnecessary browsers.
It's a tad difficult to set env variables before the package install because you don't have usual solutions such ascross-env
, but this one should be cross-platform. It is based on this Stack Overflow question -
TypeScript works out of the box in Playwright. However at the moment I have trouble with Jest and Playwright typings interacting, when writing tests in TypeScript. I've tried this tip used for Cypress, with no success though: https://stackoverflow.com/questions/58999086/cypress-causing-type-errors-in-jest-assertions
Eventually this seems to work, defining a tsconfig.json at the root of my e2e test folder:
{
"extends": "../../tsconfig.json",
"compilerOptions": {
},
"exclude": [
"jest"
],
"include": [
"./**/*.spec.ts"
]
}
But to be confirmed, behaviour can be slightly erratic.
-
It may be tempting to use Jest as the test runner, however
@playwright/test
is the recommended way -
The
electron.launch
command expects your app to be correctly built, you may need to adapt the params (a good practice is to runelectron .
, which will in turn look for the main file from yourpackage.json
). -
electronApp.firstWindow
never ends for me, andelectronApp.windows
is an empty array. I am using Electron v7, maybe it's too old?
So I am almost there with Playwright but I seem to need a more recent version of Electron for "windows" to be detected as expected. Also I couldn't fix the bad interaction with Jest typings, that are global and clashes with expect.
from spectron.
How well does playwright handle different versions of electron? Is there a need for a similar compatibility table as spectron has for different versions of electron?
from spectron.
Update: it does work with Electron v9+, it correctly gets the window from "firstWindow", but not for earlier versions. Which I guess is ok these days for people maintaining apps in the long run.
- v7 is almost mandatory anyway, because in introduce "invoke"/"handle" to get a decent API and allow to get rid of remote progressively
- v8, v9 do not have significant breaking change compared to v7, so upgrade path is easy
from spectron.
Hi guys, any idea how to grab dialogs with Playwright Electron? Eg when uploading a file? FileChooser
doesn't seem to be the most appropriate, see microsoft/playwright#5013, but the dialog doesn't appear as a window object either.
This package seems to address the issue, but I didn't test it yet: https://github.com/wsw0108/playwright-fake-dialog
I suspect also that keypress events are caught by the browser app but not electron menu, it might require some mocking/programmatic trigger as well. We can couple evaluate
and getting the app menu to force triggering relevant actions.
Finally, console.log
doesn't work in electronApp.evaluate
, that's smth to be careful about when debugging.
from spectron.
@eric-burel Have you had a look into this comment? microsoft/playwright#8278 (comment)
from spectron.
@eric-burel Have you had a look into this comment? microsoft/playwright#8278 (comment)
Yes that's basically the same code. I've managed to make it work with evaluate
indeed, that's the goto solution to either mock the main process API or programmatically trigger it
from spectron.
Related Issues (20)
- Working docker image to run electron test headless HOT 10
- Element Wasn't Found After Upgrading my Spectron Version to 15 & Electron to 13 HOT 1
- Please release Spectron 16, compatible with electron 14 HOT 8
- api http mocking
- Module name "process" has not been loaded yet for context:
- This version of ChromeDriver only supports Chrome version 91 HOT 1
- failing to successfully launch Spectron headless in Docker on Jenkins
- Spectron test table contents
- export interface SpectronClient extends WebdriverIO.BrowserObject HOT 1
- test suddenly failing on Github Action Windows
- Support Electron 15
- is it possible to work with selenium grid using the image
- ChromeDriver / Chrome version mismatch HOT 2
- app.stop() not work, electron process stay in the background after the mocha test program exits HOT 2
- Rewrite Discussion HOT 12
- This version of ChromeDriver only supports Chrome version HOT 1
- TypeError: waitUntilWindowLoaded Cannot read property 'isLoading' of undefined HOT 5
- --
- unknown error: call function result missing int 'status' HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spectron.