google / webdriver.dart

Dart WebDriver client
https://pub.dev/packages/webdriver
Apache License 2.0
138 stars 45 forks source link

HttpException: Connection closed before full header was received #298

Open lindeer opened 6 months ago

lindeer commented 6 months ago

firefox: 117.0 geckodriver: 0.34.0 OS: fedora 38

  final proc = await Process.start(
      'geckodriver',
      ['--port=4445'],
    );
  final lines = proc.stdout.transform(utf8.decoder).transform(LineSplitter());
  await for (final line in lines) {
    if (line.contains('127.0.0.1:4445')) {
      break;
    }
  }
  final opts = Map.of(drv.Capabilities.firefox);
  final driver = await drv.createDriver(
    uri: Uri.parse('http://localhost:4445/'),
    desired: opts,
    spec: drv.WebDriverSpec.W3c,
  );

error happened:

Unhandled exception:
HttpException: Connection closed before full header was received, uri = http://localhost:4445/session

but when I changed await for as follow, everything is OK, have no idea why:

  final c = Completer();
  lines.listen((line) {
    if (line.contains('127.0.0.1:4445')) {
      c.complete();
    }
  });

  if (!c.isCompleted) {
    await c.future;
  }