Skip to content

Commit

Permalink
chore: make browser.newPage device-friendly (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Sep 28, 2020
1 parent c55f262 commit 048cc22
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions playwright/async_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5643,6 +5643,7 @@ async def newPage(
hasTouch: bool = None,
colorScheme: Literal["dark", "light", "no-preference"] = None,
acceptDownloads: bool = None,
defaultBrowserType: str = None,
) -> "Page":
"""Browser.newPage
Expand Down Expand Up @@ -5708,6 +5709,7 @@ async def newPage(
hasTouch=hasTouch,
colorScheme=colorScheme,
acceptDownloads=acceptDownloads,
defaultBrowserType=defaultBrowserType,
)
)

Expand Down
5 changes: 5 additions & 0 deletions playwright/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,13 @@ async def newPage(
hasTouch: bool = None,
colorScheme: ColorScheme = None,
acceptDownloads: bool = None,
defaultBrowserType: str = None,
) -> Page:
params = locals_to_params(locals())
# Python is strict in which variables gets passed to methods. We get this
# value from the device descriptors, thats why we have to strip it out.
if "defaultBrowserType" in params:
del params["defaultBrowserType"]
context = await self.newContext(**params)
page = await context.newPage()
page._owned_context = context
Expand Down
2 changes: 2 additions & 0 deletions playwright/sync_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5875,6 +5875,7 @@ def newPage(
hasTouch: bool = None,
colorScheme: Literal["dark", "light", "no-preference"] = None,
acceptDownloads: bool = None,
defaultBrowserType: str = None,
) -> "Page":
"""Browser.newPage
Expand Down Expand Up @@ -5941,6 +5942,7 @@ def newPage(
hasTouch=hasTouch,
colorScheme=colorScheme,
acceptDownloads=acceptDownloads,
defaultBrowserType=defaultBrowserType,
)
)
)
Expand Down
1 change: 1 addition & 0 deletions scripts/expected_api_mismatch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,4 @@ Parameter type mismatch in Selectors.register(script=): documented as Union[Call

# Device support
Missing parameter documentation: Browser.newContext(defaultBrowserType=)
Missing parameter documentation: Browser.newPage(defaultBrowserType=)

0 comments on commit 048cc22

Please sign in to comment.