1

I am new with spectron and I spend a lot of time with simple example test. I have an electron app which has loader at the beginning, and after some time it presents simple view. I want to check if header is equal "Welcome" This is my test code:

const {Application} = require('spectron')
const chaiAsPromised = require('chai-as-promised');


describe('Application set up', function () {
    this.timeout(20000)
    let app;

    beforeEach(async () => {
        app = await new Application({
            path: path-to-my-exe-electron-app
        });
        chaiAsPromised.transferPromiseness = app.transferPromiseness;
        return app.start();
    });

    afterEach(async () => {
        if (app && app.isRunning()) {
            await app.stop();
        }
    });

    it('example', async () => {
        return app.client.waitUntilWindowLoaded()
            .waitForVisible('h2', 15000)
            .getText('h2')
            .then(text => expect(text).toEqual('Welcome'));
    })
})

And in result i got error: Error: element ("h2") still not visible after 15000ms What do I do wrong? I spend some hours searching other spectron ways to achieve my goal, I tried adopt many solution but with no result.

tiger
  • 87
  • 1
  • 7

0 Answers0