Skip to content

Commit 048cc22

Browse files
authored
chore: make browser.newPage device-friendly (microsoft#203)
1 parent c55f262 commit 048cc22

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

playwright/async_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5643,6 +5643,7 @@ async def newPage(
56435643
hasTouch: bool = None,
56445644
colorScheme: Literal["dark", "light", "no-preference"] = None,
56455645
acceptDownloads: bool = None,
5646+
defaultBrowserType: str = None,
56465647
) -> "Page":
56475648
"""Browser.newPage
56485649
@@ -5708,6 +5709,7 @@ async def newPage(
57085709
hasTouch=hasTouch,
57095710
colorScheme=colorScheme,
57105711
acceptDownloads=acceptDownloads,
5712+
defaultBrowserType=defaultBrowserType,
57115713
)
57125714
)
57135715

playwright/browser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ async def newPage(
120120
hasTouch: bool = None,
121121
colorScheme: ColorScheme = None,
122122
acceptDownloads: bool = None,
123+
defaultBrowserType: str = None,
123124
) -> Page:
124125
params = locals_to_params(locals())
126+
# Python is strict in which variables gets passed to methods. We get this
127+
# value from the device descriptors, thats why we have to strip it out.
128+
if "defaultBrowserType" in params:
129+
del params["defaultBrowserType"]
125130
context = await self.newContext(**params)
126131
page = await context.newPage()
127132
page._owned_context = context

playwright/sync_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5875,6 +5875,7 @@ def newPage(
58755875
hasTouch: bool = None,
58765876
colorScheme: Literal["dark", "light", "no-preference"] = None,
58775877
acceptDownloads: bool = None,
5878+
defaultBrowserType: str = None,
58785879
) -> "Page":
58795880
"""Browser.newPage
58805881
@@ -5941,6 +5942,7 @@ def newPage(
59415942
hasTouch=hasTouch,
59425943
colorScheme=colorScheme,
59435944
acceptDownloads=acceptDownloads,
5945+
defaultBrowserType=defaultBrowserType,
59445946
)
59455947
)
59465948
)

scripts/expected_api_mismatch.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,4 @@ Parameter type mismatch in Selectors.register(script=): documented as Union[Call
100100

101101
# Device support
102102
Missing parameter documentation: Browser.newContext(defaultBrowserType=)
103+
Missing parameter documentation: Browser.newPage(defaultBrowserType=)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy