Replies: 1 comment
-
@mulgurul We just released v5 of the Electron service which contains breaking interface changes, the WDIO configuration wizard may not be updated for the new version yet. You do need to set capabilities, for the latest version of the service you should be using something like:
You also need to make sure you are importing the preload and main scripts in your app. I recommend looking at the example apps in this repo if you get stuck. Also, you are likely to get more / faster replies if you use the main WDIO discussions as there's a lot more traffic over there. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm completly new to webdriver/electron testing. I'm following the guide from https://webdriver.io/docs/desktop-testing/electron/.
I'm on OSX, node v18.17.1, Electron v25.0.1 npm v9.6.7
Here's the experience:
Create a new empty dir for the test project (Maybe it needs to be added to the App project instead?)
Run rpm create wdio@latest ./
Select “Desktop Testing - of Electron Application
Set path to: /Users/mac20rd01/Source/DPA Audio Controller Test/DPA%20Audio%20Controller/release/app/dist (Notice, this is not the path to a binary but to output from a build)
Select Mocha
Select Typescript compiler
Select generate test files
Select default location
Select spec and Allure
Select no plugins
Select to add electron as a service to test setup
Run npm install
Do npm run wdio
I get:
2023-10-03T09:17:34.637Z ERROR @wdio/config:ConfigParser: Failed loading configuration file: file:///Users/mac20rd01/Source/apptest/wdio.conf.ts: Cannot read properties of undefined (reading 'productName')
TypeError: Cannot read properties of undefined (reading 'productName')
at file:///Users/mac20rd01/Source/apptest/wdio.conf.ts:5:39
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
Ok so I add missing definition to the package.json file. Guess it expected the test project to be hacked into the App project or?
"name": "my-new-project",
"type": "module",
"build": {
"productName": "DPA Audio Controller"
},
Run npm run wdio again this time getting:
2023-10-03T09:22:36.355Z INFO @wdio/cli:launcher: Run onPrepare hook
2023-10-03T09:22:36.357Z ERROR electron-service: Error: No Electron browser found in capabilities
at ElectronLaunchService.onPrepare (file:///Users/mac20rd01/Source/apptest/node_modules/wdio-electron-service/src/launcher.ts:33:41)
at async file:///Users/mac20rd01/Source/apptest/node_modules/@wdio/cli/build/utils.js:43:17
at async Promise.all (index 0)
at async Launcher.run (file:///Users/mac20rd01/Source/apptest/node_modules/@wdio/cli/build/launcher.js:94:13)
2023-10-03T09:22:36.360Z ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
Error: No Electron browser found in capabilities
at ElectronLaunchService.onPrepare (file:///Users/mac20rd01/Source/apptest/node_modules/wdio-electron-service/src/launcher.ts:33:41)
at async file:///Users/mac20rd01/Source/apptest/node_modules/@wdio/cli/build/utils.js:43:17
at async Promise.all (index 0)
at async Launcher.run (file:///Users/mac20rd01/Source/apptest/node_modules/@wdio/cli/build/launcher.js:94:13)
Continue...
2023-10-03T09:22:36.361Z INFO @wdio/local-runner: Shutting down spawned worker
file:///Users/mac20rd01/Source/apptest/node_modules/@wdio/utils/build/driver/manager.js:12
? caps.map((cap) => {
^
TypeError: Cannot read properties of undefined (reading 'capabilities')
at file:///Users/mac20rd01/Source/apptest/node_modules/@wdio/utils/build/driver/manager.js:15:80
at Array.map ()
at mapCapabilities (file:///Users/mac20rd01/Source/apptest/node_modules/@wdio/utils/build/driver/manager.js:12:16)
at setupDriver (file:///Users/mac20rd01/Source/apptest/node_modules/@wdio/utils/build/driver/manager.js:87:12)
at Launcher.run (file:///Users/mac20rd01/Source/apptest/node_modules/@wdio/cli/build/launcher.js:99:17)
Ok what is wrong here. I thought that adding the 'electron' service should setup capabilities. It says so in the conf. file:
capabilities: [{
// no need to define any capabilities for local Electron web tests
// since service plugin takes care of setting everything up
}],
Then I've hacked around adding capabilities anyway, like:
capabilities: [{
browserName: 'chrome',
"goog:chromeOptions": { binary: '/Users/mac20rd01/Source/DPA Audio Controller Test/DPA%20Audio%20Controller/release/build/mac/DPA Audio Controller.app/Contents/MacOS/DPA Audio Controller', }
}],
I get to a place where the app starts, I see the correct menus but renderer is blank, does not seem to load/run renderer scripts.
And I get more errors in console. The app hangs, no test output:
Can anyone with some decent experience please help me getting it up and running, thanks
Best regards, Peter from Denmark
Beta Was this translation helpful? Give feedback.
All reactions