3

Open a new tab manually on a browser open by Playwright


I am using Playwright for Python to open a browser, visit a URL and then do some action.

  1. Can I keep the browser's window open after my code runs?
  2. If I put a breakpoint in my Python code, I can not open a new tab in the browser open by Playwright: the page stays blank. What can I do to keep that tab open?

My code:

from playwright.sync_api import sync_playwright
    
playwright = sync_playwright().start()
browser = playwright.chromium.launch(headless=False)
context = browser.new_context()
auth_page = context.new_page()
auth_page.goto("https://www.toto.fr/")
print('Put breakpoint here')

1 Answer 1

8

Replace your breakpoint by auth_page.pause()

You can learn more about the api page.pause() here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.