[BUG] UnhandledPromiseRejectionWarning: Error: by Firefox and web kit.
Context:
- Playwright Version: "playwright": "^1.0.2"
- Operating System: [e.g. Windows 10]
- Node version: [e.g. 12.17.0]
- Browser: [Firefox, WebKit]
- Extra: [any specific details about your environment]
Code Snippet
Help us help you! Put down a short code snippet that illustrates your bug and that we can run and debug locally. For example:
const playwright = require('playwright');
(async() =>{
const browser = await playwright.firefox.launch({headless:false});
const context = await browser.newContext();
const page = await context.newPage();
await page.goto("www.amazon.com");
})();
Describe the bug After installing node and npm i playwright and running the file using command "node ./filename.js" The firefox launches for few milli sec but throws below mentioned error. And then firefox.exe goes missing from \AppData\Local\ms-playwright\firefox-1089\firefox folder.
D:\Abhay\code\test>node TestAd.js
(node:3244) UnhandledPromiseRejectionWarning: Error: Navigation failed because b
rowser has disconnected! while navigating to http://www.amazon.com while navigating to http://www.amazon.com
at D:\Abhay\code\node_modules\playwright-core\lib\frames.js:865:71
-- ASYNC --
at Frame.<anonymous> (D:\Abhay\code\node_modules\playwright-core\lib\
helper.js:63:23)
at Page.goto (D:\Abhay\code\node_modules\playwright-core\lib\page.js:
192:33)
at Page.<anonymous> (D:\Abhay\code\node_modules\playwright-core\lib\h
elper.js:64:31)
at D:\Abhay\code\test\TestAd.js:20:16
(node:3244) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This
error originated either by throwing inside of an async function without a catch
block, or by rejecting a promise which was not handled with .catch(). To termina
te the node process on unhandled promise rejection, use the CLI flag `--unhandle
d-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejectio
ns_mode). (rejection id: 1)
(node:3244) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre
cated. In the future, promise rejections that are not handled will terminate the
Node.js process with a non-zero exit code.
In second attempt of running the same test using node ./Test.js
(node:896) UnhandledPromiseRejectionWarning: Error: Failed to launch browser: E
ror: spawn C:\Users\Abhay\AppData\Local\ms-playwright\firefox-1089\firefo
\firefox.exe ENOENT
at ChildProcess.--unhandle
-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejectio
s_mode). (rejection id: 1)
(node:896) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre
ated. In the future, promise rejections that are not handled will terminate the
Node.js process with a non-zero exit code.
Facing Same error as there is no firefox file in the folder
@pooja-genpact - Was Firefox downloaded during npm install playwright? Are you able to use the other browsers (chromium, webkit)?
@abhay5 - I'm a bit lost on how firefox.exe was removed from the directory. Can you share more on your setup - what version of Node? Is this npm/yarn? How are you running the script? Also, are you able to use the other browsers (chromium, webkit)?
@pooja-genpact - Was Firefox downloaded during npm install playwright? Are you able to use the other browsers (chromium, webkit)?
Chromium is working fine but npm install playwright doesn't install firefox and webkit in APPDATA folder. I tries npm install playwright-firefox. It create folder in node-module folder but doesnot download binaries in common location. Please help with the command to download binaries
Thanks @pooja-genpact. Can you please share the output logs when you run npm install playwright-firefox?
Please reopen if the issue persists.
Hi Guys, I've reproduced the same exception with the following packages versions:
Playwright Version: "playwright": "^1.3.0" Operating System: [Windows 10] Node version: [v12.18.3] Browser: [Firefox, Chromium]
//Code const { chromium, firefox } = require('playwright');
(async () => {
//browser in context
const browser = await chromium.launch();
const context = await browser.newContext();
//page
const page = await context.newPage();
//navigate to page
page.goto("https://www.google.com/");
//Close browser
await browser.close();
})();
Still need to reopen or create a new one?
@dneprokos Could you please paste the full exception text here? There are many possible reasons for UnhandledPromiseRejectionWarning, so we have to know the exact details.
Hi @dgozman , I'm also facing same issue when using chrome browser and below is the exception text, my node version is v12.16.1
Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.
at ProgressController.run (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/progress.js:73:30)
at runNavigationTask (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/frames.js:961:23)
at Frame.goto (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/frames.js:284:16)
at Frame.goto (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/helper.js:79:31)
at /Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/page.js:203:61
at Page._attributeToPage (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/page.js:356:20)
at Page.goto (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/page.js:203:21)
at Page.goto (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/helper.js:79:31)
at /Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/src/firstTest.js:12:16
(node:91754) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:91754) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@saranyaeaswaran There should also be a specific error message before the Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.. Could you please paste that?
@dneprokos Could you please paste the full exception text here? There are many possible reasons for UnhandledPromiseRejectionWarning, so we have to know the exact details.
@dgozman Sorry, just saw your message. That's all I have after running 'node loginPageTests.js' command. At least in console. Please tell me if you need some more information. Thanks.
(node:27572) UnhandledPromiseRejectionWarning: Error: page.goto: Navigation failed because page was closed! =========================== logs =========================== [api] navigating to "https://www.google.com/", waiting until "load"
Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.
at C:\TestProjects\TestPlaywriteTests\node_modules\playwright\lib\frames.js:927:59
-- ASYNC --
at Frame.goto (C:\TestProjects\TestPlaywriteTests\node_modules\playwright\lib\helper.js:79:23)
at C:\TestProjects\TestPlaywriteTests\node_modules\playwright\lib\page.js:208:61
at Page._attributeToPage (C:\TestProjects\TestPlaywriteTests\node_modules\playwright\lib\page.js:370:20)
at Page.goto (C:\TestProjects\TestPlaywriteTests\node_modules\playwright\lib\page.js:208:21)
at Page.goto (C:\TestProjects\TestPlaywriteTests\node_modules\playwright\lib\helper.js:80:31)
at C:\TestProjects\TestPlaywriteTests\tests\loginPageTests.js:13:10
(node:27572) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:27572) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@dneprokos Thank you for the details. Unfortunately, this does not tell me much - the navigation did not even start, but no idea why. Could you try to run with DEBUG=pw:protocol,pw:api environment variable and share the (large) output it produces? Note that it contains sensitive bits like cookies, so please do not share unless you are comfortable. You can send it to [email protected] instead of sharing.
Closing since we cannot reproduce the issue.