diff --git a/playwright/async_api.py b/playwright/async_api.py index a5a03b722..bfe014d69 100644 --- a/playwright/async_api.py +++ b/playwright/async_api.py @@ -810,6 +810,15 @@ class ElementHandle(JSHandle): def __init__(self, obj: ElementHandleImpl): super().__init__(obj) + def toString(self) -> str: + """ElementHandle.toString + + Returns + ------- + str + """ + return mapping.from_maybe_impl(self._impl_obj.toString()) + def asElement(self) -> typing.Union["ElementHandle", NoneType]: """ElementHandle.asElement diff --git a/playwright/element_handle.py b/playwright/element_handle.py index f90b41644..e4f8e4364 100644 --- a/playwright/element_handle.py +++ b/playwright/element_handle.py @@ -51,6 +51,9 @@ def __init__( ) -> None: super().__init__(parent, type, guid, initializer) + def toString(self) -> str: + return self._preview + def asElement(self) -> Optional["ElementHandle"]: return self diff --git a/playwright/sync_api.py b/playwright/sync_api.py index 3ab2b617c..584e5e316 100644 --- a/playwright/sync_api.py +++ b/playwright/sync_api.py @@ -830,6 +830,15 @@ class ElementHandle(JSHandle): def __init__(self, obj: ElementHandleImpl): super().__init__(obj) + def toString(self) -> str: + """ElementHandle.toString + + Returns + ------- + str + """ + return mapping.from_maybe_impl(self._impl_obj.toString()) + def asElement(self) -> typing.Union["ElementHandle", NoneType]: """ElementHandle.asElement diff --git a/scripts/documentation_provider.py b/scripts/documentation_provider.py index 0452d1364..9ba78de7e 100644 --- a/scripts/documentation_provider.py +++ b/scripts/documentation_provider.py @@ -43,6 +43,29 @@ }, } +expected_mismatches = [ + "Download.createReadStream", + "Browser.startTracing", + "Browser.stopTracing", + "Logger.log", + "BrowserContext.setHTTPCredentials", # deprecated + "BrowserContext.serviceWorkers", # CR only (and the following) + "BrowserContext.backgroundPages", + "Browser.newBrowserCDPSession", + "Page.coverage", + "Coverage.startCSSCoverage", + "Coverage.stopCSSCoverage", + "Coverage.startJSCoverage", + "Coverage.stopJSCoverage", + "BrowserContext.newCDPSession", + "Logger.isEnabled", + "BrowserServer.kill", # not relevant for RPC clients (and the following) + "BrowserType.launchServer", + "BrowserServer.close", + "BrowserServer.process", + "BrowserServer.wsEndpoint", +] + class DocumentationProvider: def __init__(self) -> None: @@ -371,6 +394,7 @@ def rewrite_param_name(self, fqname: str, method_name: str, name: str) -> str: return name def print_remainder(self) -> None: + remainders = set() for [class_name, value] in self.api.items(): class_name = re.sub(r"Chromium(.*)", r"\1", class_name) class_name = re.sub(r"WebKit(.*)", r"\1", class_name) @@ -379,8 +403,15 @@ def print_remainder(self) -> None: if method["kind"] == "event": continue entry = f"{class_name}.{method_name}" - if entry not in self.printed_entries: - print(f"Method not implemented: {entry}", file=stderr) + if ( + entry not in self.printed_entries + and entry not in expected_mismatches + ): + remainders.add(f"Method not implemented: {entry}") + for remainder in remainders: + print(remainder, file=stderr) + if len(remainders) > 0: + exit(1) if __name__ == "__main__": diff --git a/scripts/generate_async_api.py b/scripts/generate_async_api.py old mode 100644 new mode 100755 index a7835c936..660a1c12d --- a/scripts/generate_async_api.py +++ b/scripts/generate_async_api.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # Copyright (c) Microsoft Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/generate_sync_api.py b/scripts/generate_sync_api.py old mode 100644 new mode 100755 index 7b2717d1f..553d15771 --- a/scripts/generate_sync_api.py +++ b/scripts/generate_sync_api.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # Copyright (c) Microsoft Corporation. # # Licensed under the Apache License, Version 2.0 (the "License");