mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Merge pull request #19109 from delesseps/master
Nightmare: Add typeInterval constructor option and screenshot overload for clipping path
This commit is contained in:
10
types/nightmare/index.d.ts
vendored
10
types/nightmare/index.d.ts
vendored
@@ -5,7 +5,7 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare class Nightmare {
|
||||
constructor(options?: Nightmare.IConstructorOptions);
|
||||
@@ -95,7 +95,10 @@ declare class Nightmare {
|
||||
removeListener(event: 'prompt', cb: (msg: string, defaultValue?: string) => void): Nightmare;
|
||||
removeListener(event: 'error', cb: (msg: string, trace?: Nightmare.IStackTrace[]) => void): Nightmare;
|
||||
removeListener(event: 'timeout', cb: (msg: string) => void): Nightmare;
|
||||
screenshot(path: string): Nightmare;
|
||||
screenshot(done?: (err: any, buffer: Buffer) => void): Nightmare;
|
||||
screenshot(path: string, done?: (err: any) => void): Nightmare;
|
||||
screenshot(clip: { x: number, y: number, width: number, height: number }, done?: (err: any, buffer: Buffer) => void): Nightmare;
|
||||
screenshot(path: string, clip?: { x: number, y: number, width: number, height: number }, done?: (err: any) => void): Nightmare;
|
||||
html(path: string, saveType: string): Nightmare;
|
||||
html(path: string, saveType: 'HTMLOnly'): Nightmare;
|
||||
html(path: string, saveType: 'HTMLComplete'): Nightmare;
|
||||
@@ -134,6 +137,9 @@ declare namespace Nightmare {
|
||||
cookiesFile?: string;
|
||||
phantomPath?: string;
|
||||
show?: boolean;
|
||||
typeInterval?: number;
|
||||
x?: number;
|
||||
y?: number;
|
||||
}
|
||||
|
||||
export interface IRequest {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
import Nightmare = require("nightmare");
|
||||
|
||||
|
||||
new Nightmare()
|
||||
.goto('http://yahoo.com')
|
||||
.type('input[title="Search"]', 'github nightmare')
|
||||
@@ -167,6 +165,25 @@ new Nightmare()
|
||||
.screenshot('test/test.png')
|
||||
.run(done);
|
||||
|
||||
new Nightmare()
|
||||
.goto('http://yahoo.com')
|
||||
.screenshot((err, buffer) => {
|
||||
console.log(Buffer.isBuffer(buffer));
|
||||
})
|
||||
.run(done);
|
||||
|
||||
new Nightmare()
|
||||
.goto('http://yahoo.com')
|
||||
.screenshot('test/test.png', { x: 10, y: 5, width: 10, height: 10})
|
||||
.run(done);
|
||||
|
||||
new Nightmare()
|
||||
.goto('http://yahoo.com')
|
||||
.screenshot({ x: 10, y: 5, width: 10, height: 10}, (err, buffer) => {
|
||||
console.log(Buffer.isBuffer(buffer));
|
||||
})
|
||||
.run(done);
|
||||
|
||||
new Nightmare()
|
||||
.goto('http://yahoo.com')
|
||||
.pdf('test/test.pdf')
|
||||
|
||||
Reference in New Issue
Block a user