Best Python code snippet using playwright-python
_assertions.py
Source:_assertions.py
...515 pattern: Pattern, match_substring: bool, normalize_white_space: bool516) -> ExpectedTextValue:517 expected = ExpectedTextValue(518 regexSource=pattern.pattern,519 regexFlags=escape_regex_flags(pattern),520 matchSubstring=match_substring,521 normalizeWhiteSpace=normalize_white_space,522 )523 return expected524def to_expected_text_values(525 items: Union[List[Pattern], List[str], List[Union[str, Pattern]]],526 match_substring: bool = False,527 normalize_white_space: bool = False,528) -> List[ExpectedTextValue]:529 out: List[ExpectedTextValue] = []530 assert isinstance(items, list)531 for item in items:532 if isinstance(item, str):533 out.append(...
_locator.py
Source:_locator.py
...66 self._dispatcher_fiber = frame._connection._dispatcher_fiber67 if has_text:68 if isinstance(has_text, Pattern):69 pattern = escape_with_quotes(has_text.pattern, '"')70 flags = escape_regex_flags(has_text)71 self._selector += f' >> :scope:text-matches({pattern}, "{flags}")'72 else:73 escaped = escape_with_quotes(has_text, '"')74 self._selector += f" >> :scope:has-text({escaped})"75 if has:76 if has._frame != frame:77 raise Error('Inner "has" locator must belong to the same frame.')78 self._selector += " >> has=" + json.dumps(has._selector)79 def __repr__(self) -> str:80 return f"<Locator frame={self._frame!r} selector={self._selector!r}>"81 async def _with_element(82 self,83 task: Callable[[ElementHandle, float], Awaitable[T]],84 timeout: float = None,...
_str_utils.py
Source:_str_utils.py
...23 return char + escaped_text.replace('"', '\\"') + char24 if char == "`":25 return char + escaped_text.replace("`", "\\`") + char26 raise ValueError("Invalid escape char")27def escape_regex_flags(pattern: Pattern) -> str:28 flags = ""29 if pattern.flags != 0:30 flags = ""31 if (pattern.flags & int(re.IGNORECASE)) != 0:32 flags += "i"33 if (pattern.flags & int(re.DOTALL)) != 0:34 flags += "s"35 if (pattern.flags & int(re.MULTILINE)) != 0:36 flags += "m"37 assert (38 pattern.flags39 & ~(int(re.MULTILINE) | int(re.IGNORECASE) | int(re.DOTALL) | int(re.UNICODE))40 == 041 ), "Unexpected re.Pattern flag, only MULTILINE, IGNORECASE and DOTALL are supported."...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!