electron-userland / spectron

DEPRECATED: 🔎 Test Electron apps using ChromeDriver
http://electronjs.org/spectron
MIT License
1.68k stars 228 forks source link

element.waitForExist() doesn't seem to work #718

Open mwopitz opened 4 years ago

mwopitz commented 4 years ago

While writing a bunch of UI tests, I noticed this weird issue. I can't really tell if it's caused by Spectron or by WebdriverIO or by me being stupid.

I'm using:

Here's my sample test file:

const Application = require('spectron').Application;
const assert = require('assert');
const electronPath = require('electron');
const path = require('path');

describe('Spectron', function() {
    this.timeout(0);
    this.slow(10000);

    const app = new Application({
        path: electronPath,
        args: [ path.resolve(__dirname, '..') ]
    });

    it('should start the app', async function() {
        await app.start();
    });

    it('should find #app with client.waitForExist()', async function() {
        await app.client.waitForExist('#app');
    });

    it('should find #app with client.$().isExisting()', async function() {
        const exists = await app.client.$('#app').isExisting();
        assert.strictEqual(exists, true);
    });

    it('should find #app with client.$().waitForExist()', async function() {
        await app.client.$('#app').waitForExist();
    });

    it('should close the app', async function() {
        await app.stop();
    });
});

When I execute that file with Mocha, I get the following test results:


  Spectron
    √ should start the app
    √ should find #app with client.waitForExist()
    √ should find #app with client.$().isExisting()
    1) should find #app with client.$().waitForExist()
    √ should close the app

  4 passing (8s)
  1 failing

  1) Spectron
       should find #app with client.$().waitForExist():
     Error: element ("#app") still not existing after 5000ms
      at new WaitUntilTimeoutError (node_modules\webdriverio\build\lib\utils\ErrorHandler.js:149:12)
      at C:\████████████\hello-electron\node_modules\webdriverio\build\lib\commands\waitUntil.js:29:19

Why does the test fail? Any help would be much appreciated. 😃

opitzmic commented 3 years ago

This issue was present in Spectron 10. As of Spectron 12, WebdriverIO's $ method works fine.

I'd say the issue is resolved.