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')
Mike
  • 1,080
  • 1
  • 9
  • 25

1 Answers1

4

Replace your breakpoint by auth_page.pause()

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

YasserKaddour
  • 880
  • 11
  • 23