CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

How can I attach to electron window?

Open DenisChulkov opened this issue 8 years ago • 5 comments

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

DenisChulkov avatar Dec 13 '17 13:12 DenisChulkov

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.

DavertMik avatar Dec 13 '17 23:12 DavertMik

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?

BrunoExterckotter avatar Sep 23 '19 13:09 BrunoExterckotter

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?

modze-dev avatar Jan 22 '20 19:01 modze-dev

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!

carolord999 avatar Oct 22 '20 15:10 carolord999

Hi @carolord999 , I’m really interested into using your idea .Do you have any git project where I can check? Thank you 😊

gabrielaObogeanu95 avatar Feb 21 '21 20:02 gabrielaObogeanu95