1

I am trying to automate, in flutter web integration_test, wherein I want to select multiple widgets by long pressing shift key and mouse drag. May I know if this is possible, if yes, then how? or if not possible, then is there any alternate way to achieve this selection?

For reference, I have attached an image to get more clarity if my objective. enter image description here

Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30

1 Answers1

1

To hold the shift you can try like this

await simulateKeyDownEvent(LogicalKeyboardKey.shiftLeft);

You can try creating a gesture then starting it based on location

final Offset firstLocation = tester.getCenter(find.byKey('keyName'));
final TestGesture gesture = await tester.startGesture(firstLocation, pointer: 5);
    await tester.pump();

Then to drag you can use

final Offset secondLocation = tester.getCenter(find.byKey('Key2Name'));
    await gesture.moveTo(secondLocation);
    await tester.pump();

Then do gesuture.up

 await gesture.up();

and to release shift you can do

await simulateKeyUpEvent(LogicalKeyboardKey.shiftLeft);
Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30
  • First of all, apologies for delayed acknowledgement. Was busy with some other tasks in hand. You are a savior! Your solution is amazing. Works for me. – Sourabh Shastri Aug 23 '22 at 07:10