File tree Expand file tree Collapse file tree 1 file changed +42
-3
lines changed
pkg-py/src/shinychat/playwright Expand file tree Collapse file tree 1 file changed +42
-3
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- from typing import Literal
3+ from typing import Literal , Pattern , Union
44
55from playwright .sync_api import Locator , Page
66from playwright .sync_api import expect as playwright_expect
7- from shiny .playwright ._types import PatternOrStr , Timeout
8- from shiny .playwright .controller ._base import UiBase
7+
8+ PatternStr = Pattern [str ]
9+ PatternOrStr = Union [str , PatternStr ]
10+ Timeout = Union [float , None ]
11+
12+
13+ # Avoid circular import with shiny.playwright by copy/pasting UiBase class
14+ class UiBase :
15+ """A base class representing shiny UI components."""
16+
17+ id : str
18+ """
19+ The browser DOM `id` of the UI element.
20+ """
21+ loc : Locator
22+ """
23+ Playwright `Locator` of the UI element.
24+ """
25+ page : Page
26+ """
27+ Playwright `Page` of the Shiny app.
28+ """
29+
30+ def __init__ (
31+ self ,
32+ page : Page ,
33+ * ,
34+ id : str ,
35+ loc : Locator | str ,
36+ ) -> None :
37+ self .page = page
38+ # Needed?!? This is covered by `self.loc_root` and possibly `self.loc`
39+ self .id = id
40+ if isinstance (loc , str ):
41+ loc = page .locator (loc )
42+ self .loc = loc
43+
44+ @property
45+ def expect (self ):
46+ """Expectation method equivalent to `playwright.expect(self.loc)`."""
47+ return playwright_expect (self .loc )
948
1049
1150class Chat (UiBase ):
You can’t perform that action at this time.
0 commit comments