Spectron : app.client.click is not a function

334 views Asked by At

I am testing a simple electron app using Spectron. following is my test.js having a test case to click an element.

const Application = require('spectron').Application;
const assert = require('assert');
const electronPath = require('electron'); // Require Electron from the binaries included in node_modules.
const path = require('path');

describe('Application launch', function () {
  this.timeout(30000);

  beforeEach(function () {
    this.app = new Application({
      path: electronPath,
      args: [path.join(__dirname, '..')]
    });
    return this.app.start();
  });

  afterEach(function () {
    if (this.app && this.app.isRunning()) {
      return this.app.stop();
    }
  });

  it('shows an initial window', function () {
    return this.app.client.getWindowCount().then(function (count) {
      assert.equal(count, 1);
    });
  });

  it('Navigate to settings', async function () {
    return this.app.client.click('#settings').then(function (data) {
      console.log(data);
    });
  });
});

When I run mocha following is the output.

    √ shows an initial window
    1) Navigate to settings


  1 passing (45s)
  1 failing

  1) Application launch
       Navigate to settings:
     TypeError: this.app.client.click is not a function
      at Context.<anonymous> (test\test.js:30:28)
      at process._tickCallback (internal/process/next_tick.js:68:7)



npm ERR! Test failed.  See above for more details.

I am new to mocha testing and I am unable to find a solution. Thanks in advance.

0

There are 0 answers