File tree 1 file changed +15
-7
lines changed
1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 4
4
from types import TracebackType
5
5
from typing import Any
6
6
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
+ )
8
14
9
15
from idom import html
10
16
from idom .config import IDOM_TESTING_DEFAULT_TIMEOUT
@@ -30,22 +36,24 @@ def __init__(
30
36
self .page = driver
31
37
else :
32
38
self ._browser = driver
33
- self ._next_view_id = 0
34
39
35
40
async def show (
36
41
self ,
37
42
component : RootComponentConstructor ,
38
43
) -> 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 )
43
45
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
45
47
46
48
async def goto (self , path : str , query : Any | None = None ) -> None :
47
49
await self .page .goto (self .backend .url (path , query ))
48
50
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" )
55
+ return element
56
+
49
57
async def __aenter__ (self ) -> DisplayFixture :
50
58
es = self ._exit_stack = AsyncExitStack ()
51
59
You can’t perform that action at this time.
0 commit comments