Skip to content
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

chore: roll to Playwright ToT #1576

Merged
merged 1 commit into from
Oct 5, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->106.0.5249.30<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Chromium <!-- GEN:chromium-version -->107.0.5304.18<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| WebKit <!-- GEN:webkit-version -->16.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->104.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->105.0.1<!-- GEN:stop --> | ✅ | ✅ | ✅ |

## Documentation

Expand Down
6 changes: 2 additions & 4 deletions playwright/_impl/_browser_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,7 @@ def _on_request_failed(
page: Optional[Page],
) -> None:
request._failure_text = failure_text
if request._timing:
request._timing["responseEnd"] = response_end_timing
request._set_response_end_timing(response_end_timing)
self.emit(BrowserContext.Events.RequestFailed, request)
if page:
page.emit(Page.Events.RequestFailed, request)
Expand All @@ -463,8 +462,7 @@ def _on_request_finished(
response_end_timing: float,
page: Optional[Page],
) -> None:
if request._timing:
request._timing["responseEnd"] = response_end_timing
request._set_response_end_timing(response_end_timing)
self.emit(BrowserContext.Events.RequestFinished, request)
if page:
page.emit(Page.Events.RequestFinished, request)
Expand Down
54 changes: 36 additions & 18 deletions playwright/_impl/_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
from playwright._impl._playwright import Playwright


FormType = Dict[str, Union[bool, float, str]]
DataType = Union[Any, bytes, str]
MultipartType = Dict[str, Union[bytes, bool, float, str, FilePayload]]
ParamsType = Dict[str, Union[bool, float, str]]


class APIRequest:
def __init__(self, playwright: "Playwright") -> None:
self.playwright = playwright
Expand Down Expand Up @@ -94,11 +100,11 @@ async def dispose(self) -> None:
async def delete(
self,
url: str,
params: Dict[str, Union[bool, float, str]] = None,
params: ParamsType = None,
headers: Headers = None,
data: Union[Any, bytes, str] = None,
form: Dict[str, Union[bool, float, str]] = None,
multipart: Dict[str, Union[bytes, bool, float, str, FilePayload]] = None,
data: DataType = None,
form: FormType = None,
multipart: MultipartType = None,
timeout: float = None,
failOnStatusCode: bool = None,
ignoreHTTPSErrors: bool = None,
Expand All @@ -121,8 +127,11 @@ async def delete(
async def head(
self,
url: str,
params: Dict[str, Union[bool, float, str]] = None,
params: ParamsType = None,
headers: Headers = None,
data: DataType = None,
form: FormType = None,
multipart: MultipartType = None,
timeout: float = None,
failOnStatusCode: bool = None,
ignoreHTTPSErrors: bool = None,
Expand All @@ -133,6 +142,9 @@ async def head(
method="HEAD",
params=params,
headers=headers,
data=data,
form=form,
multipart=multipart,
timeout=timeout,
failOnStatusCode=failOnStatusCode,
ignoreHTTPSErrors=ignoreHTTPSErrors,
Expand All @@ -142,8 +154,11 @@ async def head(
async def get(
self,
url: str,
params: Dict[str, Union[bool, float, str]] = None,
params: ParamsType = None,
headers: Headers = None,
data: DataType = None,
form: FormType = None,
multipart: MultipartType = None,
timeout: float = None,
failOnStatusCode: bool = None,
ignoreHTTPSErrors: bool = None,
Expand All @@ -154,6 +169,9 @@ async def get(
method="GET",
params=params,
headers=headers,
data=data,
form=form,
multipart=multipart,
timeout=timeout,
failOnStatusCode=failOnStatusCode,
ignoreHTTPSErrors=ignoreHTTPSErrors,
Expand All @@ -163,10 +181,10 @@ async def get(
async def patch(
self,
url: str,
params: Dict[str, Union[bool, float, str]] = None,
params: ParamsType = None,
headers: Headers = None,
data: Union[Any, bytes, str] = None,
form: Dict[str, Union[bool, float, str]] = None,
data: DataType = None,
form: FormType = None,
multipart: Dict[str, Union[bytes, bool, float, str, FilePayload]] = None,
timeout: float = None,
failOnStatusCode: bool = None,
Expand All @@ -190,10 +208,10 @@ async def patch(
async def put(
self,
url: str,
params: Dict[str, Union[bool, float, str]] = None,
params: ParamsType = None,
headers: Headers = None,
data: Union[Any, bytes, str] = None,
form: Dict[str, Union[bool, float, str]] = None,
data: DataType = None,
form: FormType = None,
multipart: Dict[str, Union[bytes, bool, float, str, FilePayload]] = None,
timeout: float = None,
failOnStatusCode: bool = None,
Expand All @@ -217,10 +235,10 @@ async def put(
async def post(
self,
url: str,
params: Dict[str, Union[bool, float, str]] = None,
params: ParamsType = None,
headers: Headers = None,
data: Union[Any, bytes, str] = None,
form: Dict[str, Union[bool, float, str]] = None,
data: DataType = None,
form: FormType = None,
multipart: Dict[str, Union[bytes, bool, float, str, FilePayload]] = None,
timeout: float = None,
failOnStatusCode: bool = None,
Expand All @@ -244,11 +262,11 @@ async def post(
async def fetch(
self,
urlOrRequest: Union[str, network.Request],
params: Dict[str, Union[bool, float, str]] = None,
params: ParamsType = None,
method: str = None,
headers: Headers = None,
data: Union[Any, bytes, str] = None,
form: Dict[str, Union[bool, float, str]] = None,
data: DataType = None,
form: FormType = None,
multipart: Dict[str, Union[bytes, bool, float, str, FilePayload]] = None,
timeout: float = None,
failOnStatusCode: bool = None,
Expand Down
66 changes: 65 additions & 1 deletion playwright/_impl/_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,17 @@
parse_result,
serialize_argument,
)
from playwright._impl._locator import FrameLocator, Locator
from playwright._impl._locator import (
FrameLocator,
Locator,
get_by_alt_text_selector,
get_by_label_selector,
get_by_placeholder_selector,
get_by_role_selector,
get_by_test_id_selector,
get_by_text_selector,
get_by_title_selector,
)
from playwright._impl._network import Response
from playwright._impl._set_input_files_helpers import convert_input_files
from playwright._impl._wait_helper import WaitHelper
Expand Down Expand Up @@ -520,6 +530,60 @@ def locator(
) -> Locator:
return Locator(self, selector, has_text=has_text, has=has)

def get_by_alt_text(
self, text: Union[str, Pattern[str]], exact: bool = None
) -> "Locator":
return self.locator(get_by_alt_text_selector(text, exact=exact))

def get_by_label(
self, text: Union[str, Pattern[str]], exact: bool = None
) -> "Locator":
return self.locator(get_by_label_selector(text, exact=exact))

def get_by_placeholder(
self, text: Union[str, Pattern[str]], exact: bool = None
) -> "Locator":
return self.locator(get_by_placeholder_selector(text, exact=exact))

def get_by_role(
self,
role: str,
checked: bool = None,
disabled: bool = None,
expanded: bool = None,
includeHidden: bool = None,
level: int = None,
name: Union[str, Pattern[str]] = None,
pressed: bool = None,
selected: bool = None,
) -> "Locator":
return self.locator(
get_by_role_selector(
role,
checked=checked,
disabled=disabled,
expanded=expanded,
includeHidden=includeHidden,
level=level,
name=name,
pressed=pressed,
selected=selected,
)
)

def get_by_test_id(self, testId: str) -> "Locator":
return self.locator(get_by_test_id_selector(testId))

def get_by_text(
self, text: Union[str, Pattern[str]], exact: bool = None
) -> "Locator":
return self.locator(get_by_text_selector(text, exact=exact))

def get_by_title(
self, text: Union[str, Pattern[str]], exact: bool = None
) -> "Locator":
return self.locator(get_by_title_selector(text, exact=exact))

def frame_locator(self, selector: str) -> FrameLocator:
return FrameLocator(self, selector)

Expand Down