@@ -38,6 +38,23 @@ final context = TestContext();
3838final devToolsLoadTime = const Duration (seconds: 4 );
3939
4040void main () async {
41+ Future <void > waitForDartDevToolsWithRetry ({
42+ int retryCount = 6 ,
43+ Duration retryWait = const Duration (seconds: 1 ),
44+ }) async {
45+ if (retryCount == 0 ) return ;
46+ var windows = await context.webDriver.windows.toList ();
47+ await context.webDriver.driver.switchTo.window (windows.last);
48+ final title = await context.webDriver.title;
49+ if (title == 'Dart DevTools' ) return ;
50+
51+ await Future .delayed (retryWait);
52+ return waitForDartDevToolsWithRetry (
53+ retryCount: retryCount-- ,
54+ retryWait: retryWait,
55+ );
56+ }
57+
4158 for (var useSse in [true , false ]) {
4259 group (useSse ? 'SSE' : 'WebSockets' , () {
4360 group ('Without encoding' , () {
@@ -76,11 +93,9 @@ void main() async {
7693 await context.extensionConnection.sendCommand ('Runtime.evaluate' , {
7794 'expression' : 'fakeClick()' ,
7895 });
79- await Future .delayed (devToolsLoadTime);
80- var windows = await context.webDriver.windows.toList ();
81- await context.webDriver.driver.switchTo.window (windows.last);
96+ await waitForDartDevToolsWithRetry ();
8297 expect (await context.webDriver.title, 'Dart DevTools' );
83- }, skip : 'https://github.com/dart-lang/webdev/issues/1512' );
98+ });
8499 });
85100
86101 group ('With a sharded Dart app' , () {
@@ -154,11 +169,9 @@ void main() async {
154169 await context.extensionConnection.sendCommand ('Runtime.evaluate' , {
155170 'expression' : 'fakeClick()' ,
156171 });
157- await Future .delayed (devToolsLoadTime);
158- var windows = await context.webDriver.windows.toList ();
159- await context.webDriver.driver.switchTo.window (windows.last);
172+ await waitForDartDevToolsWithRetry ();
160173 expect (await context.webDriver.title, 'Dart DevTools' );
161- }, skip : 'https://github.com/dart-lang/webdev/issues/1512' );
174+ });
162175 });
163176 });
164177 }
0 commit comments