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] How do I debug within a browser instance? #2711

Closed
saviomuc opened this issue Jun 25, 2020 · 2 comments
Closed

[Question] How do I debug within a browser instance? #2711

saviomuc opened this issue Jun 25, 2020 · 2 comments
Assignees

Comments

@saviomuc
Copy link

saviomuc commented Jun 25, 2020

Hello!

I hope you can help me with (a hopefully trivial) question. I couldn't find an answer when searching issues for various combination of debugging playwright in chrome dev tools.

I am trying to launch a chromium session with devtools enabled.
When there is a debugger statement code execution should be halted.
Example setup:

browser = debug await chromium.launch({
   headless: false,
   devtools: true,
})
context = await browser.newContext();
page = await context.newPage();

// some other setup code
await page.goto('http://localhost/somepath');
await page.waitForSelector('h3'});

debugger;

// some other code

Unfortunately code is not halted and I can not step through. Is there anything I am missing?

@arjunattam
Copy link
Contributor

Hi @saviomuc! To use the debugger keyword, you will need to run the script with an additional flag for node, like this:

node --inspect-brk script.js

Alternatively, you can setup Node debugging in VS Code (with a launch.json file). If you are on VS Code 1.40+, you can run the "Create JavaScript Debug Terminal" command to launch a new debug-friendly terminal. Any node scripts launched from this terminal will respect the debugger keyword. This last feature depends on the new JS debugger - see how to enable.

Assigning myself to add this to our docs. Thanks for the suggestion!

@arjunattam arjunattam self-assigned this Jun 25, 2020
@saviomuc
Copy link
Author

saviomuc commented Jun 26, 2020

Thanks for the quick reply @arjun27 . I was trying this with jest (node --inspect-brk node_modules/.bin/jest --runInBand --watch). Unfortunately it doesn't work with watch flag but I found a related issue. In the meantime I am able to debug single tests in non-watch mode.

I guess as the problem is not really related to playwright this issue can be closed.

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

3 participants