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 1.27 #1581

Merged
merged 1 commit into from
Oct 7, 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
86 changes: 86 additions & 0 deletions playwright/_impl/_api_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,89 @@ class FrameExpectResult(TypedDict):
matches: bool
received: Any
log: List[str]


AriaRole = Literal[
"alert",
"alertdialog",
"application",
"article",
"banner",
"blockquote",
"button",
"caption",
"cell",
"checkbox",
"code",
"columnheader",
"combobox",
"complementary",
"contentinfo",
"definition",
"deletion",
"dialog",
"directory",
"document",
"emphasis",
"feed",
"figure",
"form",
"generic",
"grid",
"gridcell",
"group",
"heading",
"img",
"insertion",
"link",
"list",
"listbox",
"listitem",
"log",
"main",
"marquee",
"math",
"menu",
"menubar",
"menuitem",
"menuitemcheckbox",
"menuitemradio",
"meter",
"navigation",
"none",
"note",
"option",
"paragraph",
"presentation",
"progressbar",
"radio",
"radiogroup",
"region",
"row",
"rowgroup",
"rowheader",
"scrollbar",
"search",
"searchbox",
"separator",
"slider",
"spinbutton",
"status",
"strong",
"subscript",
"superscript",
"switch",
"tab",
"table",
"tablist",
"tabpanel",
"term",
"textbox",
"time",
"timer",
"toolbar",
"tooltip",
"tree",
"treegrid",
"treeite",
]
4 changes: 2 additions & 2 deletions playwright/_impl/_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from pyee import EventEmitter

from playwright._impl._api_structures import FilePayload, Position
from playwright._impl._api_structures import AriaRole, FilePayload, Position
from playwright._impl._api_types import Error
from playwright._impl._connection import (
ChannelOwner,
Expand Down Expand Up @@ -547,7 +547,7 @@ def get_by_placeholder(

def get_by_role(
self,
role: str,
role: AriaRole,
checked: bool = None,
disabled: bool = None,
expanded: bool = None,
Expand Down
10 changes: 5 additions & 5 deletions playwright/_impl/_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
)

from playwright._impl._api_structures import (
AriaRole,
FilePayload,
FloatRect,
FrameExpectOptions,
Expand Down Expand Up @@ -229,7 +230,7 @@ def get_by_placeholder(

def get_by_role(
self,
role: str,
role: AriaRole,
checked: bool = None,
disabled: bool = None,
expanded: bool = None,
Expand Down Expand Up @@ -664,7 +665,7 @@ def get_by_placeholder(

def get_by_role(
self,
role: str,
role: AriaRole,
checked: bool = None,
disabled: bool = None,
expanded: bool = None,
Expand Down Expand Up @@ -739,8 +740,7 @@ def get_by_attribute_text_selector(
) -> str:
if isinstance(text, Pattern):
return f"internal:attr=[{attr_name}=/{text.pattern}/{escape_regex_flags(text)}]"
suffix = "s" if exact else "i"
return f"internal:attr=[{attr_name}={escape_for_attribute_selector(text)}{suffix}]"
return f"internal:attr=[{attr_name}={escape_for_attribute_selector(text, exact=exact)}]"


def get_by_label_selector(text: Union[str, Pattern[str]], exact: bool = None) -> str:
Expand All @@ -766,7 +766,7 @@ def get_by_text_selector(text: Union[str, Pattern[str]], exact: bool = None) ->


def get_by_role_selector(
role: str,
role: AriaRole,
checked: bool = None,
disabled: bool = None,
expanded: bool = None,
Expand Down
3 changes: 2 additions & 1 deletion playwright/_impl/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

from playwright._impl._accessibility import Accessibility
from playwright._impl._api_structures import (
AriaRole,
FilePayload,
FloatRect,
PdfMargins,
Expand Down Expand Up @@ -752,7 +753,7 @@ def get_by_placeholder(

def get_by_role(
self,
role: str,
role: AriaRole,
checked: bool = None,
disabled: bool = None,
expanded: bool = None,
Expand Down
9 changes: 3 additions & 6 deletions playwright/_impl/_str_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ def escape_for_text_selector(
return text


def escape_for_attribute_selector(value: str) -> str:
# TODO: this should actually be
# cssEscape(value).replace(/\\ /g, ' ')
# However, our attribute selectors do not conform to CSS parsing spec,
# so we escape them differently.
return '"' + value.replace('"', '\\"') + '"'
def escape_for_attribute_selector(value: str, exact: bool = None) -> str:
suffix = "" if exact else "i"
return '"' + value.replace('"', '\\"') + '"' + suffix