diff --git a/types/nightmare/index.d.ts b/types/nightmare/index.d.ts index 1af05002d3..f61c23c987 100644 --- a/types/nightmare/index.d.ts +++ b/types/nightmare/index.d.ts @@ -30,6 +30,8 @@ declare class Nightmare { uncheck(seletor: string): Nightmare; select(seletor: string, option: string): Nightmare; upload(selector: string, path: string): Nightmare; + download(path:string): Nightmare; + download(action: Nightmare.IDownloadActions): Nightmare; scrollTo(top: number, left: number): Nightmare; viewport(width: number, height: number): Nightmare; inject(type: string, file: string): Nightmare; @@ -134,6 +136,11 @@ declare namespace Nightmare { cookiesFile?: string; phantomPath?: string; show?: boolean; + paths?: { + downloads?:string; + }; + maxDownloadRequestWait?:number; + ignoreDownloads?:boolean; } export interface IRequest { @@ -171,6 +178,10 @@ declare namespace Nightmare { line: number; function?: string; } + export enum IDownloadActions { + cancel = "cancel", + continue = "continue" + } export class Cookies { get(): [Nightmare.ICookie]; get(name: string): Nightmare.ICookie; diff --git a/types/nightmare/nightmare-tests.ts b/types/nightmare/nightmare-tests.ts index 921e961538..b07a13bc6f 100644 --- a/types/nightmare/nightmare-tests.ts +++ b/types/nightmare/nightmare-tests.ts @@ -343,3 +343,9 @@ new Nightmare() new Nightmare() .goto('https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select') .select('select[name=select]', 'value3'); + +new Nightmare() + .goto('https://github.com/segmentio/nightmare') + .click('a[href="/segmentio/nightmare/archive/master.zip"]') + .download('/some/other/path/master.zip'); + .run(done);