@@ -180,8 +180,6 @@ class TestContext {
180
180
'--port=$chromeDriverPort ' ,
181
181
'--url-base=$chromeDriverUrlBase ' ,
182
182
]);
183
- // On windows this takes a while to boot up, wait for the first line
184
- // of stdout as a signal that it is ready.
185
183
final stdOutLines =
186
184
chromeDriver.stdout
187
185
.transform (utf8.decoder)
@@ -194,14 +192,31 @@ class TestContext {
194
192
.transform (const LineSplitter ())
195
193
.asBroadcastStream ();
196
194
197
- stdOutLines.listen (
198
- (line) => _logger.finest ('ChromeDriver stdout: $line ' ),
199
- );
195
+ // Sometimes ChromeDriver can be slow to startup.
196
+ // This was seen on a github actions run:
197
+ // > 11:22:59.924700: ChromeDriver stdout: Starting ChromeDriver
198
+ // > 139.0.7258.154 ([...]) on port 38107
199
+ // > [...]
200
+ // > 11:23:00.237350: ChromeDriver stdout: ChromeDriver was started
201
+ // > successfully on port 38107.
202
+ // Where in the 300+ ms it took before it was actually ready to accept
203
+ // a connection we had tried - and failed - to connect.
204
+ // We therefore wait until ChromeDriver reports that it has started
205
+ // successfully.
206
+
207
+ final chromeDriverStartup = Completer ();
208
+ stdOutLines.listen ((line) {
209
+ if (! chromeDriverStartup.isCompleted &&
210
+ line.contains ('was started successfully' )) {
211
+ chromeDriverStartup.complete ();
212
+ }
213
+ _logger.finest ('ChromeDriver stdout: $line ' );
214
+ });
200
215
stdErrLines.listen (
201
216
(line) => _logger.warning ('ChromeDriver stderr: $line ' ),
202
217
);
203
218
204
- await stdOutLines.first ;
219
+ await chromeDriverStartup.future ;
205
220
} catch (e) {
206
221
throw StateError (
207
222
'Could not start ChromeDriver. Is it installed?\n Error: $e ' ,
0 commit comments