-
Notifications
You must be signed in to change notification settings - Fork 1
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
17 and 18: Fix Target weirdness. #19
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9a7ad7e
17 and 18: fix logging after .first etc. and make Targets look like L…
perrygoy 6190e30
fix access to dunders (h/t @bandophahita).
perrygoy 986d6c1
use stubfile to override typing (h/t @bandophahita).
perrygoy 3a9f64d
remove incorrect test.
perrygoy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
"""Used to overwrite type hints for Locator methods from Playwright. | ||
|
||
Hopefully this is only temporary. -pgoy 2024-JUL-12 | ||
""" | ||
|
||
from collections import UserString | ||
from dataclasses import dataclass | ||
from typing import Pattern, TypedDict | ||
|
||
from playwright.sync_api import FrameLocator, Locator | ||
from screenpy import Actor as Actor | ||
from typing_extensions import NotRequired, Self, Unpack | ||
|
||
from .abilities import BrowseTheWebSynchronously as BrowseTheWebSynchronously | ||
from .exceptions import TargetingError as TargetingError | ||
|
||
_ManipulationArgsType = tuple[str | int | None, ...] | ||
|
||
class _ManipulationKwargsType(TypedDict): | ||
has_text: NotRequired[str | Pattern[str] | None] | ||
has_not_text: NotRequired[str | Pattern[str] | None] | ||
has: NotRequired[Locator | None] | ||
has_not: NotRequired[Locator | None] | ||
exact: NotRequired[bool | None] | ||
checked: NotRequired[bool | None] | ||
disabled: NotRequired[bool | None] | ||
expanded: NotRequired[bool | None] | ||
include_hidden: NotRequired[bool | None] | ||
level: NotRequired[int | None] | ||
name: NotRequired[str | Pattern[str] | None] | ||
pressed: NotRequired[bool | None] | ||
selected: NotRequired[bool | None] | ||
|
||
@dataclass | ||
class _Manipulation(UserString): | ||
def __hash__(self) -> int: ... | ||
def __eq__(self, other: object) -> bool: ... | ||
def __getattr__(self, name: str) -> Target | _Manipulation: ... | ||
def __call__( | ||
self, | ||
*args: Unpack[_ManipulationArgsType], | ||
**kwargs: Unpack[_ManipulationKwargsType], | ||
) -> Target: ... | ||
def get_locator(self) -> str: ... | ||
def __init__( | ||
self, | ||
target: Target, | ||
name: str, | ||
args: _ManipulationArgsType | None = ..., | ||
kwargs: _ManipulationKwargsType | None = ..., | ||
) -> None: ... | ||
|
||
class Target(FrameLocator, Locator): | ||
manipulations: list[_Manipulation] | ||
first: Target | ||
last: Target | ||
owner: Target | ||
content_frame: Target | ||
@classmethod | ||
def the(cls, name: str) -> Self: ... | ||
def located_by(self, locator: str) -> Target: ... | ||
def in_frame(self, frame_locator: str) -> Target: ... | ||
def __getattribute__(self, name: str) -> _Manipulation: ... | ||
@property | ||
def target_name(self) -> str: ... | ||
@target_name.setter | ||
def target_name(self, value: str) -> None: ... | ||
def found_by(self, the_actor: Actor) -> Locator: ... | ||
def __init__(self, name: str | None = None) -> None: ... | ||
|
||
# overridden Locator methods | ||
def and_(self, locator: Locator | Target) -> Target: ... | ||
def filter( | ||
self, | ||
*, | ||
has_text: str | Pattern | None = None, | ||
has_not_text: str | Pattern | None = None, | ||
has: Locator | Target | None = None, | ||
has_not: Locator | Target | None = None, | ||
) -> Target: ... | ||
def frame_locator(self, selector: str) -> Target: ... | ||
def get_by_alt_text( | ||
self, text: str | Pattern, *, exact: bool | None = None | ||
) -> Target: ... | ||
def get_by_label( | ||
self, text: str | Pattern, *, exact: bool | None = None | ||
) -> Target: ... | ||
def get_by_placeholder( | ||
self, text: str | Pattern, *, exact: bool | None = None | ||
) -> Target: ... | ||
def get_by_role( | ||
self, | ||
role: str, | ||
*, | ||
checked: bool | None = None, | ||
disabled: bool | None = None, | ||
expanded: bool | None = None, | ||
include_hidden: bool | None = None, | ||
level: int | None = None, | ||
name: str | Pattern | None = None, | ||
pressed: bool | None = None, | ||
selected: bool | None = None, | ||
exact: bool | None = None, | ||
) -> Target: ... | ||
def get_by_test_id(self, test_id: str | Pattern) -> Target: ... | ||
def get_by_text( | ||
self, text: str | Pattern, *, exact: bool | None = None | ||
) -> Target: ... | ||
def get_by_title( | ||
self, text: str | Pattern, *, exact: bool | None = None | ||
) -> Target: ... | ||
def locator( | ||
self, | ||
selector: str | Locator, | ||
*, | ||
has_text: str | Pattern | None = None, | ||
has_not_text: str | Pattern | None = None, | ||
has: Locator | Target | None = None, | ||
has_not: Locator | Target | None = None, | ||
) -> Target: ... | ||
def nth(self, index: int) -> Target: ... | ||
def or_(self, locator: Locator | Target) -> Target: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change handles the Target being correctly logged. Before, for a Target like:
Logging would be like:
rather than what it is now: