How do I run UI tests on an Android App having a Flutter module integrated in it?

Viewed 130

I have an android app which, has a separate flutter module integrated within it.

So when my app launches, I initialise the flutter engine and load it in a Flutter fragment. So all my initial screens are rendered from the flutter module.

I have tried:

Appium's flutter driver- APK installs and runs smoothly. But I am not able to access any flutter widgets. Not sure if this is happening because flutter is being run in a fragment as a module.

Flutter test driver- Also, since the flutter module is integrated as a separate module, running flutter tests using the test driver doesn't work.

Is there any way to run the UI tests on the flutter code which is loaded into the android app as a module?

code structure is something like:

|- Android App
|-|-Flutter module
|-|-|- .Android module
|-|-|- .iOS module
|-|-Android modules
1 Answers

Ensure enableFlutterDriverExtension() is the first line in main.dart class and add the key as Value key

Ex

                   InkWell(
                      child: Container(
                        key: ValueKey("click_container"),
                        margin: const EdgeInsets.only(top: 32.0, bottom: 30.0),
                        padding: const EdgeInsets.only(
                            top: 15.0, bottom: 15.0, left: 40.0, right: 40.0),
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(8.0),
                            color: Colors.white),
                        child: Text(
                         "Hello"
                        ),
                      )
Related