diff --git a/README.md b/README.md index 2b97d1e45..431a3eea2 100644 --- a/README.md +++ b/README.md @@ -206,11 +206,11 @@ property which do not require Node integration. #### client -Spectron uses [WebdriverIO](http://webdriver.io) and exposes the managed +Spectron uses [WebdriverIO](https://webdriver.io) and exposes the managed `client` property on the created `Application` instances. The `client` API is WebdriverIO's `browser` object. Documentation can be found -[here](http://webdriver.io/api.html). +[here](https://webdriver.io/docs/api). Several additional commands are provided specific to Electron. @@ -219,8 +219,10 @@ All the commands return a `Promise`. So if you wanted to get the text of an element you would do: ```js -app.client.getText('#error-alert').then(function (errorText) { - console.log('The #error-alert text content is ' + errorText) +app.client.$('#error-alert').then(function (element) { + element.getText().then(function (errorText) { + console.log('The #error-alert text content is ' + errorText) + }) }) ``` @@ -237,9 +239,8 @@ API in your tests you would do: ```js app.electron.clipboard.writeText('pasta') - .electron.clipboard.readText().then(function (clipboardText) { - console.log('The clipboard text is ' + clipboardText) - }) +const clipboardText = app.electron.clipboard.readText() +console.log('The clipboard text is ' + clipboardText) ``` #### browserWindow @@ -649,7 +650,7 @@ test.afterEach(t => { return t.context.app.stop(); }); -test(t => { +test('opens a window', t => { return t.context.app.client.waitUntilWindowLoaded() .getWindowCount().then(count => { t.is(count, 1); @@ -686,7 +687,7 @@ test.afterEach.always(async t => { await t.context.app.stop(); }); -test(async t => { +test('example', async t => { const app = t.context.app; await app.client.waitUntilWindowLoaded(); diff --git a/lib/spectron.d.ts b/lib/spectron.d.ts index 2fbeed8a2..deee7cf55 100644 --- a/lib/spectron.d.ts +++ b/lib/spectron.d.ts @@ -118,15 +118,19 @@ declare module 'spectron' { ): Promise; } - export interface SpectronWindow extends Electron.BrowserWindow { - capturePage(): Promise; - } + export type SpectronWindow = { + [P in keyof Electron.BrowserWindow]: Electron.BrowserWindow[P] extends ( + ...args: infer A + ) => infer R + ? (...args: A) => Promise + : undefined; + }; export interface SpectronWebContents extends Electron.WebContents { savePage( fullPath: string, saveType: 'HTMLOnly' | 'HTMLComplete' | 'MHTML', - callback?: (eror: Error) => void + callback?: (error: Error) => void ): boolean; savePage( fullPath: string,