Skip to content

Commit

Permalink
chore: roll to Playwright 1.27
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Oct 7, 2022
1 parent be076b7 commit 8acdb2d
Show file tree
Hide file tree
Showing 9 changed files with 795 additions and 31 deletions.
86 changes: 86 additions & 0 deletions playwright/_impl/_api_structures.py
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
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
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
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
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

0 comments on commit 8acdb2d

Please sign in to comment.