Merge pull request #19109 from delesseps/master

Nightmare: Add typeInterval constructor option and screenshot overload for clipping path
This commit is contained in:
Nathan Shively-Sanders
2017-09-06 16:27:58 -07:00
committed by GitHub
2 changed files with 27 additions and 4 deletions

View File

@@ -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 {

View File

@@ -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')