Skip to content

[Flutter Driver] tap on a Sliver throws an exception #67743

@Xavjer

Description

@Xavjer

Flutter driver throwing the error:
await driver.tap(find.byType('RenderSliverStickyHeader'));

Error thrown:

DriverError: Error in Flutter application: Uncaught extension error while executing tap: type 'RenderSliverStickyHeader' is not a subtype of type 'RenderBox' in type cast
  #0      _HitTestableFinder.filter.<anonymous closure> (package:flutter_test/src/finders.dart:504:52)
  #1      _SyncIterator.moveNext (dart:core-patch/core_patch.dart:165:25)
  #2      Iterable.isEmpty (dart:core/iterable.dart:440:33)
  #3      Iterable.isNotEmpty (dart:core/iterable.dart:447:27)
  #4      FlutterDriverExtension._waitForElement.<anonymous closure> (package:flutter_driver/src/extension/extension.dart:278:51)
  #5      FlutterDriverExtension._waitUntilFrame (package:flutter_driver/src/extension/extension.dart:263:19)
  #6      FlutterDriverExtension._waitForElement (package:flutter_driver/src/extension/extension.dart:278:11)
  <asynchronous suspension>
  #7      FlutterDriverExtension._tap (package:flutter_driver/src/extension/extension.dart:385:41)
  #8      FlutterDriverExtension.call (package:flutter_driver/src/extension/extension.dart:216:53)
  #9      BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart:547:32)
  <asynchronous suspension>
  #10     BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart)
  #11     _runExtension (dart:developer-patch/developer.dart:84:23)

The code from package:flutter_test/src/finders.dart that results in the error:

@override
  Iterable<Element> filter(Iterable<Element> parentCandidates) sync* {
    for (final Element candidate in parentCandidates) {
      final RenderBox box = candidate.renderObject as RenderBox;
      assert(box != null);
      final Offset absoluteOffset = box.localToGlobal(alignment.alongSize(box.size));
      final HitTestResult hitResult = HitTestResult();
      WidgetsBinding.instance!.hitTest(hitResult, absoluteOffset);
      for (final HitTestEntry entry in hitResult.path) {
        if (entry.target == candidate.renderObject) {
          yield candidate;
          break;
        }
      }
    }
  }

As this Widget is a Sliver, it cannot be cast to a RenderBox. I did not work much with Slivers, I am therefore unsure how this is correctly implemented for them. I know that they work with geometry, but I don't know how to get the absoluteOffset for the calculation.

If someone could point me to the right direction, I would create a PR for this

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: crashStack traces logged to the consolef: scrollingViewports, list views, slivers, etc.found in release: 3.3Found to occur in 3.3found in release: 3.6Found to occur in 3.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work ont: flutter driver"flutter driver", flutter_drive, or a driver testteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions