File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 44from types import TracebackType
55from typing import Any
66
7- from playwright .async_api import Browser , BrowserContext , Page , async_playwright
7+ from playwright .async_api import (
8+ Browser ,
9+ BrowserContext ,
10+ ElementHandle ,
11+ Page ,
12+ async_playwright ,
13+ )
814
915from idom import html
1016from idom .config import IDOM_TESTING_DEFAULT_TIMEOUT
@@ -30,22 +36,24 @@ def __init__(
3036 self .page = driver
3137 else :
3238 self ._browser = driver
33- self ._next_view_id = 0
3439
3540 async def show (
3641 self ,
3742 component : RootComponentConstructor ,
3843 ) -> None :
39- self ._next_view_id += 1
40- view_id = f"display-{ self ._next_view_id } "
41- self .backend .mount (lambda : html .div ({"id" : view_id }, component ()))
42-
44+ self .backend .mount (component )
4345 await self .goto ("/" )
44- await self .page . wait_for_selector ( f"# { view_id } " , state = " attached" )
46+ await self .root_element () # check that root element is attached
4547
4648 async def goto (self , path : str , query : Any | None = None ) -> None :
4749 await self .page .goto (self .backend .url (path , query ))
4850
51+ async def root_element (self ) -> ElementHandle :
52+ element = await self .page .wait_for_selector (f"#app" , state = "attached" )
53+ if element is None :
54+ raise RuntimeError ("Root element not attached" ) # pragma: no cover
55+ return element
56+
4957 async def __aenter__ (self ) -> DisplayFixture :
5058 es = self ._exit_stack = AsyncExitStack ()
5159
You can’t perform that action at this time.
0 commit comments