diff --git a/lib/Page.js b/lib/Page.js index 3fa522c6c4ee5..317b9fca996e3 100644 --- a/lib/Page.js +++ b/lib/Page.js @@ -135,7 +135,6 @@ class Page extends EventEmitter { this._client.send('Target.setAutoAttach', {autoAttach: true, waitForDebuggerOnStart: false, flatten: true}), this._client.send('Performance.enable', {}), this._client.send('Log.enable', {}), - this._client.send('Page.setInterceptFileChooserDialog', {enabled: true}), ]); } @@ -160,6 +159,9 @@ class Page extends EventEmitter { * @return !Promise} */ async waitForFileChooser(options = {}) { + if (!this._fileChooserInterceptors.size) + await this._client.send('Page.setInterceptFileChooserDialog', {enabled: true}); + const { timeout = this._timeoutSettings.timeout(), } = options;