Skip to content

Cannot convert undefined or null to object #839

Closed
@snake-py

Description

@snake-py

I am trying to set up spectron. I am unsure how to resolve this. I took the code from the docs and went throw it for a couple of days. It seems that spectron is not opening my app, instead, multiple windows appear and it is stuck in a loop. I am unsure if this is a bug or due to version incompatibility (I checked I am using electron 10.1.5 and spectron 12.0.0).

My code:

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

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

describe('Testing', function () {
  this.timeout(10000);
  beforeEach(() => {
    console.log(app); // this is executed
    return app.start(); // troubling line
  });
  afterEach(() => {
    if (app && app.isRunning()) {
      return app.stop();
    }
  });
  it('shows an initial window', function () {
    console.log('count'); // this is not executed
    // const count = app.client.getWindowCount();
    // return assert.equal(count, 1);
    assert(1,1)
  });
});

The error I got:

1) Testing
       "before each" hook for "shows an initial window":
     javascript error: javascript error: Cannot convert undefined or null to object
  (Session info: chrome=85.0.4183.121)
      at Object.getErrorFromResponseBody (node_modules\webdriver\build\utils.js:94:12)
      at WebDriverRequest._request (node_modules\webdriver\build\request.js:134:31)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
      at async Browser.wrapCommandFn (node_modules\@wdio\utils\build\shim.js:63:29)
      at async Browser.wrapCommandFn (node_modules\@wdio\utils\build\shim.js:63:29)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions