Skip to content

Commit

Permalink
Merge pull request electron-userland#897 from mtgto/fix_doc_and_type
Browse files Browse the repository at this point in the history
Fix doc and type
  • Loading branch information
VerteDinde authored Sep 16, 2021
2 parents d5d4a60 + 38044c8 commit 891321b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,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.

Expand All @@ -221,8 +221,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)
})
})
```

Expand All @@ -239,9 +241,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
Expand Down Expand Up @@ -651,7 +652,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);
Expand Down Expand Up @@ -688,7 +689,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();
Expand Down
12 changes: 8 additions & 4 deletions lib/spectron.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ declare module 'spectron' {
): Promise<AccessibilityAuditResult>;
}

export interface SpectronWindow extends Electron.BrowserWindow {
capturePage(): Promise<Electron.NativeImage>;
}
export type SpectronWindow = {
[P in keyof Electron.BrowserWindow]: Electron.BrowserWindow[P] extends (
...args: infer A
) => infer R
? (...args: A) => Promise<R>
: 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,
Expand Down

0 comments on commit 891321b

Please sign in to comment.