gpt4 book ai didi

flutter - 驱动程序错误 : Failed to fulfill Tap due to remote error flutter

转载 作者:IT王子 更新时间:2023-10-29 06:39:12 25 4
gpt4 key购买 nike

我有一些自定义的 TextFiels,它们用于输入 pin,我称它们为 PinInputField。当我使用 flutter drive 运行集成测试时,所有输入字段都将收到给定的文本,最后一个除外,并停止运行测试。这是代码:P.s:我正在使用 HookWidget

    final focusNodes = List.generate(6, (_) => new FocusNode());
final values = List.generate(6, (_) => useState<String>(''));

Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
for (int i = 0; i < values.length; i++)
PinInputField(
key: ValueKey('$i'),
width: MediaQuery.of(context).size.width / 11.71,
height: 80,
fontSize: 50,
marginRight: 16,
input: values[i],
focusNode: focusNodes[i],
nextFocusNode: i == 5 ? null : focusNodes[i + 1],
)
],
)

这是测试:

    test('test main card settings items', () async {
final cardSettingsItem = find.byValueKey('settings.cardSettings');
final mainSettingsList = find.byValueKey('mainSettingsList');
final profileButton = find.byValueKey('Profile');
final changePinButton = find.byValueKey('Cambiar pin');
final changePinInputField0 = find.byValueKey('0');
final changePinInputField1 = find.byValueKey('1');
final changePinInputField2 = find.byValueKey('2');
final changePinInputField3 = find.byValueKey('3');
final changePinInputField4 = find.byValueKey('4');
final changePinInputField5 = find.byValueKey('5');
final changePinScreenButton = find.byValueKey('changePinScreenButton');
sleep(Duration(seconds: 3));
await driver.tap(profileButton);
sleep(Duration(seconds: 2));
await driver.scrollIntoView(mainSettingsList);
sleep(Duration(seconds: 3));
await driver.tap(cardSettingsItem);
sleep(Duration(seconds: 3));
await driver.tap(changePinButton);
sleep(Duration(seconds: 4));
await driver.tap(changePinInputField0);
sleep(Duration(seconds: 2));
await driver.enterText("0");
sleep(Duration(seconds: 1));
await driver.tap(changePinInputField1);
sleep(Duration(seconds: 2));
await driver.enterText("1");
sleep(Duration(seconds: 1));
await driver.tap(changePinInputField2);
sleep(Duration(seconds: 2));
await driver.enterText("2");
sleep(Duration(seconds: 1));
await driver.tap(changePinInputField3);
sleep(Duration(seconds: 2));
await driver.enterText("3");
sleep(Duration(seconds: 1));
await driver.tap(changePinInputField4);
sleep(Duration(seconds: 2));
await driver.enterText("4");
sleep(Duration(seconds: 4));
await driver.tap(changePinInputField5);
sleep(Duration(seconds: 1));
await driver.enterText("5");
sleep(Duration(seconds: 5));
await driver.tap(changePinScreenButton);
sleep(Duration(seconds: 4));
});

这是日志:

 DriverError: Failed to fulfill Tap due to remote error
Original error: Bad state: The client closed with pending request "ext.flutter.driver".
Original stack trace:
#0 new Client.withoutJson.<anonymous closure> (package:json_rpc_2/src/client.dart:70:24)
#1 StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#2 StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#3 _rootRun (dart:async/zone.dart:1120:38)
#4 _CustomZone.run (dart:async/zone.dart:1021:19)
#5 _FutureListener.handleWhenComplete (dart:async/future_impl.dart:150:18)
#6 Future._propagateToListeners.handleWhenCompleteCallback (dart:async/future_impl.dart:609:39)
#7 Future._propagateToListeners (dart:async/future_impl.dart:665:37)
#8 Future._propagateToListeners (dart:async/future_impl.dart:566:9)
#9 Future._completeWithValue (dart:async/future_impl.dart:483:5)
#10 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
#11 StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#12 StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#13 _rootRun (dart:async/zone.dart:1124:13)
#14 _CustomZone.run (dart:async/zone.dart:1021:19)
#15 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#16 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#17 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#18 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#19 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:391:30)
#20 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#21 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)

最佳答案

此问题主要发生在测试在实际完成之前超时。用于运行测试的默认超时为 30 秒,此处您的 sleep 持续时间加起来超过 30 秒,因此连接因未决请求而关闭。

我不明白为什么每次 Action 后都要睡一段时间,也许你可以减少/消除 sleep 。如果 sleep 对于您的情况是强制性的,请尝试将适当的 timeout 传递给测试。

例子:

test(
'test main card settings items',
() async {
final cardSettingsItem = find.byValueKey('settings.cardSettings');
final mainSettingsList = find.byValueKey('mainSettingsList');
final profileButton = find.byValueKey('Profile');
final changePinButton = find.byValueKey('Cambiar pin');
final changePinInputField0 = find.byValueKey('0');
final changePinInputField1 = find.byValueKey('1');
final changePinInputField2 = find.byValueKey('2');
final changePinInputField3 = find.byValueKey('3');
final changePinInputField4 = find.byValueKey('4');
final changePinInputField5 = find.byValueKey('5');
final changePinScreenButton = find.byValueKey('changePinScreenButton');
sleep(Duration(seconds: 3));
await driver.tap(profileButton);
sleep(Duration(seconds: 2));
await driver.scrollIntoView(mainSettingsList);
sleep(Duration(seconds: 3));
await driver.tap(cardSettingsItem);
sleep(Duration(seconds: 3));
await driver.tap(changePinButton);
sleep(Duration(seconds: 4));
await driver.tap(changePinInputField0);
sleep(Duration(seconds: 2));
await driver.enterText("0");
sleep(Duration(seconds: 1));
await driver.tap(changePinInputField1);
sleep(Duration(seconds: 2));
await driver.enterText("1");
sleep(Duration(seconds: 1));
await driver.tap(changePinInputField2);
sleep(Duration(seconds: 2));
await driver.enterText("2");
sleep(Duration(seconds: 1));
await driver.tap(changePinInputField3);
sleep(Duration(seconds: 2));
await driver.enterText("3");
sleep(Duration(seconds: 1));
await driver.tap(changePinInputField4);
sleep(Duration(seconds: 2));
await driver.enterText("4");
sleep(Duration(seconds: 4));
await driver.tap(changePinInputField5);
sleep(Duration(seconds: 1));
await driver.enterText("5");
sleep(Duration(seconds: 5));
await driver.tap(changePinScreenButton);
sleep(Duration(seconds: 4));
},
timeout: Timeout(
Duration(minutes: 2),
),
);

希望对您有所帮助!

关于flutter - 驱动程序错误 : Failed to fulfill Tap due to remote error flutter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57013127/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com