Skip to content

chore: validate properties in the docs #424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions playwright/_impl/_chromium_browser_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ def _on_service_worker(self, worker: Worker) -> None:
self._service_workers.add(worker)
self.emit(ChromiumBrowserContext.Events.ServiceWorker, worker)

@property
def background_pages(self) -> List[Page]:
return list(self._background_pages)

@property
def service_workers(self) -> List[Worker]:
return list(self._service_workers)

Expand Down
5 changes: 3 additions & 2 deletions playwright/_impl/_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pathlib
from pathlib import Path
from typing import Dict, Optional, Union

Expand Down Expand Up @@ -39,8 +40,8 @@ async def delete(self) -> None:
async def failure(self) -> Optional[str]:
return patch_error_message(await self._channel.send("failure"))

async def path(self) -> Optional[str]:
return await self._channel.send("path")
async def path(self) -> Optional[pathlib.Path]:
return pathlib.Path(await self._channel.send("path"))

async def save_as(self, path: Union[str, Path]) -> None:
path = str(Path(path))
Expand Down
1 change: 0 additions & 1 deletion playwright/_impl/_file_chooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def page(self) -> "Page":
def element(self) -> "ElementHandle":
return self._element_handle

@property
def is_multiple(self) -> bool:
return self._is_multiple

Expand Down
7 changes: 0 additions & 7 deletions playwright/_impl/_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,6 @@ async def wait_for_function(
async def title(self) -> str:
return await self._channel.send("title")

def expect_load_state(
self,
state: DocumentLoadState = None,
timeout: float = None,
) -> EventContextManagerImpl:
return EventContextManagerImpl(self.wait_for_load_state(state, timeout))

def expect_navigation(
self,
url: URLMatch = None,
Expand Down
1 change: 0 additions & 1 deletion playwright/_impl/_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ async def response(self) -> Optional["Response"]:
def frame(self) -> "Frame":
return from_channel(self._initializer["frame"])

@property
def is_navigation_request(self) -> bool:
return self._initializer["isNavigationRequest"]

Expand Down
8 changes: 1 addition & 7 deletions playwright/_impl/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ async def set_viewport_size(self, viewportSize: ViewportSize) -> None:
self._viewport_size = viewportSize
await self._channel.send("setViewportSize", locals_to_params(locals()))

@property
def viewport_size(self) -> Optional[ViewportSize]:
return self._viewport_size

Expand Down Expand Up @@ -882,13 +883,6 @@ def expect_file_chooser(
self.wait_for_event("filechooser", predicate, timeout)
)

def expect_load_state(
self,
state: DocumentLoadState = None,
timeout: float = None,
) -> EventContextManagerImpl:
return EventContextManagerImpl(self.wait_for_load_state(state, timeout))

def expect_navigation(
self,
url: URLMatch = None,
Expand Down
13 changes: 9 additions & 4 deletions playwright/_impl/_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import pathlib
from typing import TYPE_CHECKING, cast

if TYPE_CHECKING: # pragma: no cover
Expand All @@ -26,13 +27,17 @@ def __init__(self, page: "Page") -> None:
self._page = page
self._path_future = page._loop.create_future()

async def path(self) -> str:
async def path(self) -> pathlib.Path:
return await self._path_future

def _set_relative_path(self, relative_path: str) -> None:
self._path_future.set_result(
os.path.join(
cast(str, self._page._browser_context._options["recordVideo"]["dir"]),
relative_path,
pathlib.Path(
os.path.join(
cast(
str, self._page._browser_context._options["recordVideo"]["dir"]
),
relative_path,
)
)
)
Loading