Skip to content

Commit

Permalink
chore: use offical pw methods instead of dunder defs (microsoft#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Oct 3, 2020
1 parent 55380b3 commit 20a6e7c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pytest_playwright/pytest_playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,13 @@ def launch(**kwargs: Dict[Any, Any]) -> Browser:
launch_options = {**browser_type_launch_args, **kwargs}
if headful_option:
launch_options["headless"] = False
pw_context = sync_playwright()
pw = pw_context.__enter__()
pw = sync_playwright().start()
browser = getattr(pw, browser_name).launch(**launch_options)
browser._close = browser.close

def _handle_close() -> None:
browser._close()
pw_context.__exit__(None, None, None)
pw.stop()

browser.close = _handle_close
return browser
Expand Down

0 comments on commit 20a6e7c

Please sign in to comment.