Loss of webdriverio session when testing restarting an electronic application using a spectron

I use spectron to run integration tests with my electronic application. Everything works fine, except trying to verify that the application settings are saved properly between application restarts.

When running tests, my application launches with a new temporary userData directory for each test, which ensures that the tests are isolated. This means that persistence testing should ideally be performed in one test, and for this I need to restart the application in the middle of the test. There is an app.restart method, so should it be supported correctly?

I am using the following test code:

 // save some settings here await app.restart(); await app.client.waitUntilWindowLoaded() // do some more checking to ensure the app is fully loaded // check the settings here 

However, I get the following error:

 Error: waitUntilWindowLoaded Promise was rejected with the following reason: Error: A session id is required for this command but wasn't found in the response payload 

What is the right way to do this? I also tried to stop the application instance and start a new one with similar results.

+7
electron webdriver-io spectron
source share
2 answers

It works

 // save some settings here await app.stop(); app = new Application({ ... }); await app.start(); await app.client.waitUntilWindowLoaded(); // do some more checking to ensure the app is fully loaded // check the settings here 
0
source share

Running snippsets,

 import test from 'ava' import util from '../util' test(async t => { // This runs after each test and other test hooks, even if they failed let app = util.createApp() app = await util.waitForLoad(app, t) await app.restart() await app.client.waitUntilWindowLoaded() // app = await util.waitForLoad(app, t) }) 

works with "spectron": "^3.5.0"

0
source share

All Articles