Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 驱动程序问题,无法按键找到小部件_Flutter_Integration Testing - Fatal编程技术网

Flutter 驱动程序问题,无法按键找到小部件

Flutter 驱动程序问题,无法按键找到小部件,flutter,integration-testing,Flutter,Integration Testing,我在SerializableFinder中按键查找小部件时遇到了一个问题,我能做些什么来解决这个问题 我已经尝试过用常量制作密钥,并且通过提供常量来检查密钥是否与finder中的密钥相同。此外,我指的是这个链接: 代码如下: 集成测试文件(示例部分,非完整代码): 查找器文件(用于底部导航栏): 小部件文件(2部分): 第1部分:底部导航栏项 List<BottomNavigationBarItem> bottomNavigationBarItems = [ BottomNa

我在SerializableFinder中按键查找小部件时遇到了一个问题,我能做些什么来解决这个问题

我已经尝试过用常量制作密钥,并且通过提供常量来检查密钥是否与finder中的密钥相同。此外,我指的是这个链接:

代码如下: 集成测试文件(示例部分,非完整代码):

查找器文件(用于底部导航栏):

小部件文件(2部分): 第1部分:底部导航栏项

List<BottomNavigationBarItem> bottomNavigationBarItems = [
    BottomNavigationBarItem(
        icon: Icon(Icons.cake, key: Key(DESSERT)), title: Text("Dessert")),
    BottomNavigationBarItem(
        icon: Icon(Icons.restaurant, key : Key(SEAFOOD)), title: Text("Seafood")),
    BottomNavigationBarItem(
        icon: Icon(Icons.cake, key: Key(FAVORITE_DESSERT)), title: Text("Favorite Dessert")),
    BottomNavigationBarItem(
        icon: Icon(Icons.restaurant, key: Key(FAVORITE_SEAFOOD)), title: Text("Favorite Seafood"))
  ];
如果你想提供完整的代码,只要请求它,我将非常乐意提供它们

预期结果:在进行集成测试时,应用程序将自动导航所选项目

实际结果:

偷窥:

00:02 +0: Meals Catalogue App bottom navigation bar test item
[warning] FlutterDriver: waitFor message is taking a long time to complete...
00:32 +0 -1: Meals Catalogue App bottom navigation bar test item [E]
  TimeoutException after 0:00:30.000000: Test timed out after 30 seconds.

由于链接中的堆栈跟踪有点太长,我将在此处提供我的粘贴库:

我遇到了同样的问题,最终帮助我的解决方案来自:

颤振驱动程序在默认情况下是帧同步的,它将等待直到没有挂起的帧,但是如果有无限动画,测试将转到超时并失败

要解决此问题,您需要使用
driver.runUnsynchronized()
方法包装测试。 像这样:

test('testsplashscreen',()异步{
等待驱动程序。运行未同步(()异步{
wait driver.waitFor(find.text(“甜点”));
});
});

(仅当您有无限动画或希望在动画结束前继续时)

花了8个小时试图解决此问题。谢谢
List<BottomNavigationBarItem> bottomNavigationBarItems = [
    BottomNavigationBarItem(
        icon: Icon(Icons.cake, key: Key(DESSERT)), title: Text("Dessert")),
    BottomNavigationBarItem(
        icon: Icon(Icons.restaurant, key : Key(SEAFOOD)), title: Text("Seafood")),
    BottomNavigationBarItem(
        icon: Icon(Icons.cake, key: Key(FAVORITE_DESSERT)), title: Text("Favorite Dessert")),
    BottomNavigationBarItem(
        icon: Icon(Icons.restaurant, key: Key(FAVORITE_SEAFOOD)), title: Text("Favorite Seafood"))
  ];
 bottomNavigationBar: BottomNavigationBar(
        key: Key(BOTTOM_NAVIGATION_BAR),
        items: bottomNavigationBarItems,
        currentIndex: currentIndex,
        onTap: (index) {
          changeSelectedBottomNavigationBarItem(index);
        },
        selectedItemColor: appConfig.appColor,
        unselectedItemColor: Colors.grey,
      ),
00:02 +0: Meals Catalogue App bottom navigation bar test item
[warning] FlutterDriver: waitFor message is taking a long time to complete...
00:32 +0 -1: Meals Catalogue App bottom navigation bar test item [E]
  TimeoutException after 0:00:30.000000: Test timed out after 30 seconds.
00:32 +0 -1: Meals Catalogue App (tearDownAll)
00:32 +0 -1: Meals Catalogue App bottom navigation bar test item [E]
  DriverError: Failed to fulfill WaitFor due to remote error
  Original error: Bad state: The client closed with pending request "ext.flutter.driver".