Skip to content

Commit 7b79980

Browse files
authored
chore: roll Playwright to 0.170.0-next.1605573954344 (microsoft#305)
1 parent cb7abd5 commit 7b79980

18 files changed

+356
-81
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Lint
3434
run: pre-commit run --all-files
3535
- name: Test Sync generation script
36-
run: bash buildbots/test-sync-generation.sh
36+
run: bash scripts/verify_api.sh
3737
build:
3838
name: Build
3939
timeout-minutes: 30

build_package.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@
2323

2424
from playwright.path_utils import get_file_dirname
2525

26-
driver_version_64 = "0.170.0-next.1605305660869"
27-
driver_version_32 = "0.170.0-next.1605305685932"
28-
29-
30-
def driver_version(platform: str) -> str:
31-
return driver_version_32 if platform == "win32" else driver_version_64
26+
driver_version = "0.170.0-next.1605573954344"
3227

3328

3429
if not os.path.exists("driver"):
@@ -37,7 +32,7 @@ def driver_version(platform: str) -> str:
3732
os.makedirs("playwright/driver")
3833

3934
for platform in ["mac", "linux", "win32", "win32_x64"]:
40-
zip_file = f"playwright-cli-{driver_version(platform)}-{platform}.zip"
35+
zip_file = f"playwright-cli-{driver_version}-{platform}.zip"
4136
if not os.path.exists("driver/" + zip_file):
4237
url = "https://playwright.azureedge.net/builds/cli/next/" + zip_file
4338
print("Fetching ", url)
@@ -66,7 +61,7 @@ def driver_version(platform: str) -> str:
6661
}
6762

6863
for platform in ["mac", "linux", "win32", "win32_x64"]:
69-
zip_file = f"driver/playwright-cli-{driver_version(platform)}-{platform}.zip"
64+
zip_file = f"driver/playwright-cli-{driver_version}-{platform}.zip"
7065
with zipfile.ZipFile(zip_file, "r") as zip:
7166
zip.extractall(f"driver/{platform}")
7267
if platform_map[sys.platform] == platform:

playwright/async_api.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
RequestFailure,
5555
ResourceTiming,
5656
SelectOption,
57+
SetStorageState,
58+
StorageState,
5759
Viewport,
5860
)
5961
from playwright.input import Keyboard as KeyboardImpl
@@ -463,6 +465,7 @@ async def fulfill(
463465

464466
async def continue_(
465467
self,
468+
url: str = None,
466469
method: str = None,
467470
headers: typing.Union[typing.Dict[str, str]] = None,
468471
postData: typing.Union[str, bytes] = None,
@@ -473,6 +476,8 @@ async def continue_(
473476
474477
Parameters
475478
----------
479+
url : Optional[str]
480+
If set changes the request URL. New URL must have same protocol as original one.
476481
method : Optional[str]
477482
If set changes the request method (e.g. GET or POST)
478483
headers : Optional[Dict[str, str]]
@@ -482,7 +487,10 @@ async def continue_(
482487
"""
483488
return mapping.from_maybe_impl(
484489
await self._impl_obj.continue_(
485-
method=method, headers=mapping.to_impl(headers), postData=postData
490+
url=url,
491+
method=method,
492+
headers=mapping.to_impl(headers),
493+
postData=postData,
486494
)
487495
)
488496

@@ -5721,6 +5729,17 @@ async def close(self) -> NoneType:
57215729
"""
57225730
return mapping.from_maybe_impl(await self._impl_obj.close())
57235731

5732+
async def storageState(self) -> StorageState:
5733+
"""BrowserContext.storageState
5734+
5735+
Returns storage state for this browser context, contains current cookies and local storage snapshot.
5736+
5737+
Returns
5738+
-------
5739+
{"cookies": List[Dict], "origins": List[Dict]}
5740+
"""
5741+
return mapping.from_maybe_impl(await self._impl_obj.storageState())
5742+
57245743
def expect_event(
57255744
self,
57265745
event: str,
@@ -5889,6 +5908,7 @@ async def newContext(
58895908
videoSize: IntSize = None,
58905909
recordHar: RecordHarOptions = None,
58915910
recordVideo: RecordVideoOptions = None,
5911+
storageState: SetStorageState = None,
58925912
) -> "BrowserContext":
58935913
"""Browser.newContext
58945914
@@ -5939,6 +5959,8 @@ async def newContext(
59395959
Enables HAR recording for all pages into `recordHar.path` file. If not specified, the HAR is not recorded. Make sure to await `browserContext.close` for the HAR to be saved.
59405960
recordVideo : Optional[{"dir": str, "size": Optional[{"width": int, "height": int}]}]
59415961
Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make sure to await `browserContext.close` for videos to be saved.
5962+
storageState : Optional[{"cookies": Optional[List[Dict]], "origins": Optional[List[Dict]]}]
5963+
Populates context with given storage state. This method can be used to initialize context with logged-in information obtained via browserContext.storageState().
59425964
59435965
Returns
59445966
-------
@@ -5969,6 +5991,7 @@ async def newContext(
59695991
videoSize=videoSize,
59705992
recordHar=recordHar,
59715993
recordVideo=recordVideo,
5994+
storageState=storageState,
59725995
)
59735996
)
59745997

@@ -5997,6 +6020,7 @@ async def newPage(
59976020
videoSize: IntSize = None,
59986021
recordHar: RecordHarOptions = None,
59996022
recordVideo: RecordVideoOptions = None,
6023+
storageState: SetStorageState = None,
60006024
) -> "Page":
60016025
"""Browser.newPage
60026026
@@ -6048,6 +6072,8 @@ async def newPage(
60486072
Enables HAR recording for all pages into `recordHar.path` file. If not specified, the HAR is not recorded. Make sure to await `page.close` for the HAR to be saved.
60496073
recordVideo : Optional[{"dir": str, "size": Optional[{"width": int, "height": int}]}]
60506074
Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make sure to await `page.close` for videos to be saved.
6075+
storageState : Optional[{"cookies": Optional[List[Dict]], "origins": Optional[List[Dict]]}]
6076+
Populates context with given storage state. This method can be used to initialize context with logged-in information obtained via browserContext.storageState().
60516077
60526078
Returns
60536079
-------
@@ -6078,6 +6104,7 @@ async def newPage(
60786104
videoSize=videoSize,
60796105
recordHar=recordHar,
60806106
recordVideo=recordVideo,
6107+
storageState=storageState,
60816108
)
60826109
)
60836110

playwright/browser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
ProxyServer,
2727
RecordHarOptions,
2828
RecordVideoOptions,
29+
SetStorageState,
2930
is_safe_close_error,
3031
locals_to_params,
3132
)
@@ -95,6 +96,7 @@ async def newContext(
9596
videoSize: IntSize = None,
9697
recordHar: RecordHarOptions = None,
9798
recordVideo: RecordVideoOptions = None,
99+
storageState: SetStorageState = None,
98100
) -> BrowserContext:
99101
params = locals_to_params(locals())
100102
# Python is strict in which variables gets passed to methods. We get this
@@ -143,6 +145,7 @@ async def newPage(
143145
videoSize: IntSize = None,
144146
recordHar: RecordHarOptions = None,
145147
recordVideo: RecordVideoOptions = None,
148+
storageState: SetStorageState = None,
146149
) -> Page:
147150
params = locals_to_params(locals())
148151
# Python is strict in which variables gets passed to methods. We get this

playwright/browser_context.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
PendingWaitEvent,
2727
RouteHandler,
2828
RouteHandlerEntry,
29+
StorageState,
2930
TimeoutSettings,
3031
URLMatch,
3132
URLMatcher,
@@ -235,6 +236,9 @@ async def close(self) -> None:
235236
if not is_safe_close_error(e):
236237
raise e
237238

239+
async def storageState(self) -> StorageState:
240+
return await self._channel.send_return_as_dict("storageState")
241+
238242
def expect_event(
239243
self,
240244
event: str,

playwright/connection.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ def __init__(self, connection: "Connection", guid: str) -> None:
3333
self._object: Optional[ChannelOwner] = None
3434

3535
async def send(self, method: str, params: Dict = None) -> Any:
36+
return await self.inner_send(method, params, False)
37+
38+
async def send_return_as_dict(self, method: str, params: Dict = None) -> Any:
39+
return await self.inner_send(method, params, True)
40+
41+
async def inner_send(
42+
self, method: str, params: Optional[Dict], return_as_dict: bool
43+
) -> Any:
3644
if params is None:
3745
params = {}
3846
callback = self._connection._send_message_to_server(self._guid, method, params)
@@ -42,6 +50,8 @@ async def send(self, method: str, params: Dict = None) -> Any:
4250
if not result:
4351
return None
4452
assert isinstance(result, dict)
53+
if return_as_dict:
54+
return result
4555
if len(result) == 0:
4656
return None
4757
assert len(result) == 1

playwright/helper.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
MouseButton = Literal["left", "middle", "right"]
5252

5353

54+
class StorageState(TypedDict):
55+
cookies: List[Cookie]
56+
origins: List[Dict]
57+
58+
59+
class SetStorageState(TypedDict):
60+
cookies: Optional[List[Cookie]]
61+
origins: Optional[List[Dict]]
62+
63+
5464
class MousePosition(TypedDict):
5565
x: float
5666
y: float
@@ -105,9 +115,10 @@ class Header(TypedDict):
105115

106116

107117
class ContinueParameters(TypedDict, total=False):
108-
method: str
109-
headers: List[Header]
110-
postData: str
118+
url: Optional[str]
119+
method: Optional[str]
120+
headers: Optional[List[Header]]
121+
postData: Optional[str]
111122

112123

113124
class ParsedMessageParams(TypedDict):

playwright/network.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,14 @@ async def fulfill(
182182

183183
async def continue_(
184184
self,
185+
url: str = None,
185186
method: str = None,
186187
headers: Dict[str, str] = None,
187188
postData: Union[str, bytes] = None,
188189
) -> None:
189190
overrides: ContinueParameters = {}
191+
if url:
192+
overrides["url"] = url
190193
if method:
191194
overrides["method"] = method
192195
if headers:

playwright/sync_api.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
RequestFailure,
5454
ResourceTiming,
5555
SelectOption,
56+
SetStorageState,
57+
StorageState,
5658
Viewport,
5759
)
5860
from playwright.input import Keyboard as KeyboardImpl
@@ -467,6 +469,7 @@ def fulfill(
467469

468470
def continue_(
469471
self,
472+
url: str = None,
470473
method: str = None,
471474
headers: typing.Union[typing.Dict[str, str]] = None,
472475
postData: typing.Union[str, bytes] = None,
@@ -477,6 +480,8 @@ def continue_(
477480
478481
Parameters
479482
----------
483+
url : Optional[str]
484+
If set changes the request URL. New URL must have same protocol as original one.
480485
method : Optional[str]
481486
If set changes the request method (e.g. GET or POST)
482487
headers : Optional[Dict[str, str]]
@@ -487,7 +492,10 @@ def continue_(
487492
return mapping.from_maybe_impl(
488493
self._sync(
489494
self._impl_obj.continue_(
490-
method=method, headers=mapping.to_impl(headers), postData=postData
495+
url=url,
496+
method=method,
497+
headers=mapping.to_impl(headers),
498+
postData=postData,
491499
)
492500
)
493501
)
@@ -5959,6 +5967,17 @@ def close(self) -> NoneType:
59595967
"""
59605968
return mapping.from_maybe_impl(self._sync(self._impl_obj.close()))
59615969

5970+
def storageState(self) -> StorageState:
5971+
"""BrowserContext.storageState
5972+
5973+
Returns storage state for this browser context, contains current cookies and local storage snapshot.
5974+
5975+
Returns
5976+
-------
5977+
{"cookies": List[Dict], "origins": List[Dict]}
5978+
"""
5979+
return mapping.from_maybe_impl(self._sync(self._impl_obj.storageState()))
5980+
59625981
def expect_event(
59635982
self,
59645983
event: str,
@@ -6129,6 +6148,7 @@ def newContext(
61296148
videoSize: IntSize = None,
61306149
recordHar: RecordHarOptions = None,
61316150
recordVideo: RecordVideoOptions = None,
6151+
storageState: SetStorageState = None,
61326152
) -> "BrowserContext":
61336153
"""Browser.newContext
61346154
@@ -6179,6 +6199,8 @@ def newContext(
61796199
Enables HAR recording for all pages into `recordHar.path` file. If not specified, the HAR is not recorded. Make sure to await `browserContext.close` for the HAR to be saved.
61806200
recordVideo : Optional[{"dir": str, "size": Optional[{"width": int, "height": int}]}]
61816201
Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make sure to await `browserContext.close` for videos to be saved.
6202+
storageState : Optional[{"cookies": Optional[List[Dict]], "origins": Optional[List[Dict]]}]
6203+
Populates context with given storage state. This method can be used to initialize context with logged-in information obtained via browserContext.storageState().
61826204
61836205
Returns
61846206
-------
@@ -6210,6 +6232,7 @@ def newContext(
62106232
videoSize=videoSize,
62116233
recordHar=recordHar,
62126234
recordVideo=recordVideo,
6235+
storageState=storageState,
62136236
)
62146237
)
62156238
)
@@ -6239,6 +6262,7 @@ def newPage(
62396262
videoSize: IntSize = None,
62406263
recordHar: RecordHarOptions = None,
62416264
recordVideo: RecordVideoOptions = None,
6265+
storageState: SetStorageState = None,
62426266
) -> "Page":
62436267
"""Browser.newPage
62446268
@@ -6290,6 +6314,8 @@ def newPage(
62906314
Enables HAR recording for all pages into `recordHar.path` file. If not specified, the HAR is not recorded. Make sure to await `page.close` for the HAR to be saved.
62916315
recordVideo : Optional[{"dir": str, "size": Optional[{"width": int, "height": int}]}]
62926316
Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make sure to await `page.close` for videos to be saved.
6317+
storageState : Optional[{"cookies": Optional[List[Dict]], "origins": Optional[List[Dict]]}]
6318+
Populates context with given storage state. This method can be used to initialize context with logged-in information obtained via browserContext.storageState().
62936319
62946320
Returns
62956321
-------
@@ -6321,6 +6347,7 @@ def newPage(
63216347
videoSize=videoSize,
63226348
recordHar=recordHar,
63236349
recordVideo=recordVideo,
6350+
storageState=storageState,
63246351
)
63256352
)
63266353
)

scripts/generate_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def return_value(value: Any) -> List[str]:
163163
from playwright.element_handle import ElementHandle as ElementHandleImpl
164164
from playwright.file_chooser import FileChooser as FileChooserImpl
165165
from playwright.frame import Frame as FrameImpl
166-
from playwright.helper import ConsoleMessageLocation, Credentials, MousePosition, Error, FilePayload, SelectOption, RequestFailure, Viewport, DeviceDescriptor, IntSize, FloatRect, Geolocation, ProxyServer, PdfMargins, ResourceTiming, RecordHarOptions, RecordVideoOptions
166+
from playwright.helper import ConsoleMessageLocation, Credentials, MousePosition, Error, FilePayload, SelectOption, RequestFailure, Viewport, DeviceDescriptor, IntSize, FloatRect, Geolocation, ProxyServer, PdfMargins, ResourceTiming, RecordHarOptions, RecordVideoOptions, StorageState, SetStorageState
167167
from playwright.input import Keyboard as KeyboardImpl, Mouse as MouseImpl, Touchscreen as TouchscreenImpl
168168
from playwright.js_handle import JSHandle as JSHandleImpl
169169
from playwright.network import Request as RequestImpl, Response as ResponseImpl, Route as RouteImpl, WebSocket as WebSocketImpl

scripts/test_to_python.js

100644100755
File mode changed.
File renamed without changes.

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