Codeceptjs: How can I attach to electron window?

Created on 13 Dec 2017  路  4Comments  路  Source: codeceptjs/CodeceptJS

I test application which consists of standalone electron windows. Can I attach to electron window using cedeceptjs?

enhancement

Most helpful comment

Good question, @DenisChulkov
I'd really love to see Electron support in CodeceptJS but I have only two hands and no current Electron projects.

I think it would be awesome if CodeceptJS could receive Spectron helper so we could run Electron tests with official testing driver. Good news, Spectron is based on webdriverio, so I suppose that helper would just extend WebDriverIO module.

If you have skills/ideas/time to implement that helper I'd be glad to provide you with all additional information you may need.

All 4 comments

Good question, @DenisChulkov
I'd really love to see Electron support in CodeceptJS but I have only two hands and no current Electron projects.

I think it would be awesome if CodeceptJS could receive Spectron helper so we could run Electron tests with official testing driver. Good news, Spectron is based on webdriverio, so I suppose that helper would just extend WebDriverIO module.

If you have skills/ideas/time to implement that helper I'd be glad to provide you with all additional information you may need.

Hi @DavertMik ,
I'm thinking about implement the Spectron Helper to use this in the company that I work. I'm QA Test Automation and I have a Developer to support it. Can you provide more information about it?

Hi @DavertMik, CodeceptJS also works with Test Cafe, there is a very simple solution using just a configuration file, see https://github.com/DevExpress/testcafe-browser-provider-electron. For testcafe you just need to use the notation "electron:." to work. Maybe CodeceptJS could just pass the parameters further to the test cafe electron integration?

Hi @DenisChulkov we succeeded to complete a test using CodeceptJS and TestCafe for an electron app.
First, we followed the following config page : https://www.npmjs.com/package/testcafe-browser-provider-electron

Second, here is the 'codecept.conf.js' file, where electron needs to be added to the browser's list :

exports.config = { tests: './*_test.js', output: './output', helpers: { TestCafe: { url: 'https://my.addresscom', browser: 'chrome', restart: false, waitForTimeout: 5000, show: true, } }, multiple: { basic: { // run all tests in chrome and firefox browsers: ["chrome", "firefox", "electron"], } }, include: { I: './steps_file.js' }, bootstrap: null, mocha: {}, name: 'E2E', plugins: { pauseOnFail: {}, retryFailedStep: { enabled: true }, tryTo: { enabled: true }, screenshotOnFail: { enabled: true } } }

Third, here is our '.testcafe-electron-rc.json' file config where :
mainWindowUrl = the url of the electron app
electronPath = the directory where our electron configs are

`{
"mainWindowUrl": "https://my.adresse.com/",
"appArgs": ["--env=development"],
"electronPath": "./MyApp.app"

}`

And last, here is the command to use in a shell, where "CodeceptJS test" is the name of our test :

npx codeceptjs run-multiple basic:electron --grep "CodeceptJS test"

I hope this info will help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

prashantsail picture prashantsail  路  4Comments

ybohaienko picture ybohaienko  路  4Comments

neil-s picture neil-s  路  3Comments

hanthomas picture hanthomas  路  4Comments

lets-open-source picture lets-open-source  路  4Comments