Accessing the webContents API

The webContents API can be accessed through the webContents property. This property will give you the webContents for the current window and will contain all the API. The following code matches the window title in the test case:

const { Application } = require('spectron');
const assert = require('assert')

describe('application launch', function () {
this.timeout(10000);

beforeEach(function () {
this.app = new Application({
path: './node_modules/.bin/electron',
args: ['main.js']
});
return this.app.start();
});

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

it('It should match the window title', function () {
this.app.webContents.getTitle().then(function (data) {
assert.equal(data, 'Application Title');
});
});
});

In this way, you can have the full access to the webContents API through the application object instance.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.101.192