Skip to content

Commit f5f9614

Browse files
authored
chore: add missing methods and use a set for it (#184)
* chore: add missing methods and use a set for it * fix: exit script as failure if methods are missing
1 parent 4d367d9 commit f5f9614

File tree

6 files changed

+56
-2
lines changed

6 files changed

+56
-2
lines changed

playwright/async_api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,15 @@ class ElementHandle(JSHandle):
810810
def __init__(self, obj: ElementHandleImpl):
811811
super().__init__(obj)
812812

813+
def toString(self) -> str:
814+
"""ElementHandle.toString
815+
816+
Returns
817+
-------
818+
str
819+
"""
820+
return mapping.from_maybe_impl(self._impl_obj.toString())
821+
813822
def asElement(self) -> typing.Union["ElementHandle", NoneType]:
814823
"""ElementHandle.asElement
815824

playwright/element_handle.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def __init__(
5151
) -> None:
5252
super().__init__(parent, type, guid, initializer)
5353

54+
def toString(self) -> str:
55+
return self._preview
56+
5457
def asElement(self) -> Optional["ElementHandle"]:
5558
return self
5659

playwright/sync_api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,15 @@ class ElementHandle(JSHandle):
830830
def __init__(self, obj: ElementHandleImpl):
831831
super().__init__(obj)
832832

833+
def toString(self) -> str:
834+
"""ElementHandle.toString
835+
836+
Returns
837+
-------
838+
str
839+
"""
840+
return mapping.from_maybe_impl(self._impl_obj.toString())
841+
833842
def asElement(self) -> typing.Union["ElementHandle", NoneType]:
834843
"""ElementHandle.asElement
835844

scripts/documentation_provider.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,29 @@
4343
},
4444
}
4545

46+
expected_mismatches = [
47+
"Download.createReadStream",
48+
"Browser.startTracing",
49+
"Browser.stopTracing",
50+
"Logger.log",
51+
"BrowserContext.setHTTPCredentials", # deprecated
52+
"BrowserContext.serviceWorkers", # CR only (and the following)
53+
"BrowserContext.backgroundPages",
54+
"Browser.newBrowserCDPSession",
55+
"Page.coverage",
56+
"Coverage.startCSSCoverage",
57+
"Coverage.stopCSSCoverage",
58+
"Coverage.startJSCoverage",
59+
"Coverage.stopJSCoverage",
60+
"BrowserContext.newCDPSession",
61+
"Logger.isEnabled",
62+
"BrowserServer.kill", # not relevant for RPC clients (and the following)
63+
"BrowserType.launchServer",
64+
"BrowserServer.close",
65+
"BrowserServer.process",
66+
"BrowserServer.wsEndpoint",
67+
]
68+
4669

4770
class DocumentationProvider:
4871
def __init__(self) -> None:
@@ -371,6 +394,7 @@ def rewrite_param_name(self, fqname: str, method_name: str, name: str) -> str:
371394
return name
372395

373396
def print_remainder(self) -> None:
397+
remainders = set()
374398
for [class_name, value] in self.api.items():
375399
class_name = re.sub(r"Chromium(.*)", r"\1", class_name)
376400
class_name = re.sub(r"WebKit(.*)", r"\1", class_name)
@@ -379,8 +403,15 @@ def print_remainder(self) -> None:
379403
if method["kind"] == "event":
380404
continue
381405
entry = f"{class_name}.{method_name}"
382-
if entry not in self.printed_entries:
383-
print(f"Method not implemented: {entry}", file=stderr)
406+
if (
407+
entry not in self.printed_entries
408+
and entry not in expected_mismatches
409+
):
410+
remainders.add(f"Method not implemented: {entry}")
411+
for remainder in remainders:
412+
print(remainder, file=stderr)
413+
if len(remainders) > 0:
414+
exit(1)
384415

385416

386417
if __name__ == "__main__":

scripts/generate_async_api.py

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python
12
# Copyright (c) Microsoft Corporation.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");

scripts/generate_sync_api.py

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python
12
# Copyright (c) Microsoft Corporation.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");

0 commit comments

Comments
 (0)