Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]UnhandledPromiseRejectionWarning EVERYTIME #4788

Closed
aaronportier opened this issue Dec 21, 2020 · 2 comments
Closed

[Question]UnhandledPromiseRejectionWarning EVERYTIME #4788

aaronportier opened this issue Dec 21, 2020 · 2 comments

Comments

@aaronportier
Copy link

I seem to get the error shown after the code everytime.
code:
const playwright= require('playwright');

(async function main() {

const browser = await playwright.chromium.launch({headless:false});

// const context =await broswer.newContext();

const page = await browser.newPage();

await page.goto('https://www.google.com/');
await page.waitForTimeout(5000);

await browser.close();

})
(node:4192) UnhandledPromiseRejectionWarning: ReferenceError: playwright is not defined
at C:\Users\Aarons\Desktop\playwrighttest.js:5:21
at Object. (C:\Users\Aarons\Desktop\playwrighttest.js:17:3)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
(Use node --trace-warnings ... to show where the warning was created)
<node_internals>/internal/process/warning.js:43

@gonzobard777
Copy link

try this

const playwright= require('playwright');

(async function main() {

  const browser = await playwright['chromium'].launch({headless:false});
// const context =await broswer.newContext();

  const page = await browser.newPage();

  await page.goto('https://www.google.com/');
  await page.waitForTimeout(5000);

  await browser.close();
})()

@dgozman
Copy link
Contributor

dgozman commented Dec 23, 2020

Did you install playwright? Try running npm install playwright before running the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants