-
-
Notifications
You must be signed in to change notification settings - Fork 0
API Documentation
You declare an application for each test that is run. This informs Spectron about the Electron application you would like to execute.
const Application = require("spectroscope");
const app = Application({
exec: path.join(__dirname, "/node_modules/.bin/electron"),
args: ["."],
enableConsoleOutput: false,
});
You must await app.start();
before beginning your test code and await app.stop()
after completing your test code.
Exported from WebdriverIO. Refer to documentation here.
const element = await app.$("#title");
Exported from WebdriverIO. Refer to documentation here.
const elements = await app.$$(".title");
Evaluate runs an expression on the Electron main thread with full access to the app, window (this refers to the current BrowserWindow) and BrowserWindow and returns the response to the test code.
const url = await app.evaluate(async (app, window, BrowserWindow) => window.webContents.getURL());
Execute runs an expression on the Electron main thread with full access to the app, window (this refers to the current BrowserWindow) and BrowserWindow and does not returns the response to the test code.
Execute must be used over Evaluate if the browser preload context were to change, for example when navigating to a new page as shown below.
await app.execute(async (app, window, BrowserWindow) => window.loadURL("https://otbeaumont.me"));
Note: Running this test with a content security policy enabled may result in the test failing. This is a bug in Spectroscope
Spectroscope is able to run Google Chrome's Accessibility Developer Tools to review the browser content of your application for accessibility issues.
const results = await app.auditAccessibility();
results.forEach((result) => console.error(result));