|
| 1 | +--- |
| 2 | +id: appium-flutter-integration |
| 3 | +title: Appium Flutter Integration Driver Testing |
| 4 | +sidebar_label: Flutter Integration Driver |
| 5 | +description: Guide to testing Flutter apps using Appium Flutter Integration Driver on LambdaTest real device cloud. |
| 6 | +keywords: |
| 7 | + - flutter app testing |
| 8 | + - appium flutter integration |
| 9 | + - real device testing |
| 10 | + - lambdatest |
| 11 | + - flutter automation |
| 12 | + - mobile test automation |
| 13 | +url: https://www.lambdatest.com/support/docs/appium-flutter-integration/ |
| 14 | +site_name: LambdaTest |
| 15 | +slug: appium-flutter-integration/ |
| 16 | +--- |
| 17 | + |
| 18 | +import CodeBlock from '@theme/CodeBlock'; |
| 19 | +import Tabs from '@theme/Tabs'; |
| 20 | +import TabItem from '@theme/TabItem'; |
| 21 | +import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys"; |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +LambdaTest supports testing Flutter applications on real Android and iOS devices using the [**Appium Flutter Integration Driver**](https://github.com/AppiumTestDistribution/appium-flutter-integration-driver/). This driver enables you to automate Flutter app testing in multiple programming languages, providing a powerful and flexible way to validate your Flutter apps on real devices in the cloud. |
| 26 | + |
| 27 | +Testing Flutter apps requires embedding the **Flutter Integration Server** inside your app to enable communication between Appium and Flutter UI elements. |
| 28 | + |
| 29 | +After preparing your Flutter app with this integration (refer to the setup documentation below), you can build, upload, and execute your tests on LambdaTest real devices using the Appium Flutter Integration Driver. |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## Native Flutter Integration Driver vs Appium Flutter Integration Driver |
| 34 | + |
| 35 | +| Feature / Use Case | Native Flutter Driver | Appium Flutter Integration Driver | |
| 36 | +|----------------------------------------------------|----------------------|----------------------------------| |
| 37 | +| Writing tests in languages other than Dart | No | Yes | |
| 38 | +| Support for Flutter apps with embedded webviews or native views | No | Yes | |
| 39 | +| Running tests on multiple devices simultaneously | No | Yes | |
| 40 | +| Compatible with device farms supporting Appium | No | Yes | |
| 41 | +| Interaction beyond Flutter context (e.g., OTP apps) | No | Yes | |
| 42 | + |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## Why Use Appium Flutter Integration Driver? |
| 47 | + |
| 48 | +- **Multi-language support:** Write tests in Java, Python, Ruby, JavaScript, and more. |
| 49 | +- **Automatic UI synchronization:** Waits intelligently for UI elements and animations to complete. |
| 50 | +- **Seamless context switching:** No manual switching between Flutter and native app contexts. |
| 51 | +- **Powerful gesture support:** Supports long press, drag and drop, scroll to element, double-click, and more. |
| 52 | +- **Element chaining:** Easily find child elements under specific parent widgets. |
| 53 | +- **Real device cloud ready:** Supported on LambdaTest real Android and iOS devices. |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## Getting Your Flutter App Ready for Tessting |
| 58 | + |
| 59 | +### 1. Add the Flutter Integration Server dependency |
| 60 | + |
| 61 | +In your Flutter app’s `pubspec.yaml`, add: |
| 62 | + |
| 63 | +```yaml |
| 64 | +dev_dependencies: |
| 65 | + appium_flutter_server: 0.0.28 |
| 66 | +``` |
| 67 | +
|
| 68 | +### 2. Create integration test files |
| 69 | +
|
| 70 | +Create an `integration_test` folder at the root of your Flutter project. Inside it, create `appium_test.dart` with: |
| 71 | + |
| 72 | +```dart |
| 73 | +import 'package:appium_flutter_server/appium_flutter_server.dart'; |
| 74 | +import 'package:your_app_package/main.dart'; // Replace with your app's main.dart import |
| 75 | +
|
| 76 | +void main() { |
| 77 | + initializeTest(app: const MyApp()); |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +Or with setup callback: |
| 82 | + |
| 83 | +```dart |
| 84 | +import 'package:your_app_package/main.dart' as app; |
| 85 | +
|
| 86 | +void main() { |
| 87 | + initializeTest( |
| 88 | + callback: (WidgetTester tester) async { |
| 89 | + // Add prerequisite setup here |
| 90 | + await tester.pumpWidget(const app.MyApp()); |
| 91 | + }, |
| 92 | + ); |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +### 3. Build your Flutter app with integration test |
| 97 | + |
| 98 | +<Tabs> |
| 99 | + <TabItem value="android" label="Android" default> |
| 100 | + <CodeBlock className="language-bash"> |
| 101 | +{`./gradlew app:assembleDebug -Ptarget=$(pwd)/../integration_test/appium_test.dart`} |
| 102 | + </CodeBlock> |
| 103 | + </TabItem> |
| 104 | + |
| 105 | + <TabItem value="ios-simulator" label="iOS Simulator"> |
| 106 | + <CodeBlock className="language-bash"> |
| 107 | +{`flutter build ios integration_test/appium_test.dart --simulator`} |
| 108 | + </CodeBlock> |
| 109 | + </TabItem> |
| 110 | + |
| 111 | + <TabItem value="ios-device" label="iOS Real Device"> |
| 112 | + <CodeBlock className="language-bash"> |
| 113 | +{`flutter build ipa --release integration_test/appium_test.dart`} |
| 114 | + </CodeBlock> |
| 115 | + </TabItem> |
| 116 | +</Tabs> |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Uploading Your Flutter App to LambdaTest |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | +- For detailed instructions on how to upload your application to LambdaTest, please refer to our comprehensive guide. |
| 125 | +- Visit the [**Upload your Application**](https://www.lambdatest.com/support/docs/application-setup-via-api/#upload-your-application) documentation to learn more. |
| 126 | +- Use the returned **App ID** from above step in your automation scripts. |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +## Sample Desired Capabilities |
| 133 | + |
| 134 | +<Tabs> |
| 135 | + <TabItem value="android" label="Android" default> |
| 136 | + <CodeBlock className="language-java"> |
| 137 | +{`desired_caps = { |
| 138 | + "deviceName":"Galaxy S20", |
| 139 | + "platformName":"Android", |
| 140 | + "platformVersion":"15", |
| 141 | + "isRealMobile":True, |
| 142 | + "app":"YOUR_APP_URL", |
| 143 | + "build":"Sample Build", |
| 144 | + "name":"Sample Test", |
| 145 | + "automationName": "FlutterIntegration" #Using Flutter Integration Driver |
| 146 | +} |
| 147 | + |
| 148 | +`} |
| 149 | + </CodeBlock> |
| 150 | + </TabItem> |
| 151 | +
|
| 152 | + <TabItem value="ios" label="iOS"> |
| 153 | + <CodeBlock className="language-java"> |
| 154 | +{`desired_caps = { |
| 155 | + "deviceName":"iPhone 16", |
| 156 | + "platformName":"ios", |
| 157 | + "platformVersion":"18", |
| 158 | + "isRealMobile":True, |
| 159 | + "app":"YOUR_APP_URL", |
| 160 | + "build":"Sample Build", |
| 161 | + "name":"Sample Test", |
| 162 | + "automationName": "FlutterIntegration" #Using Flutter Integration Driver |
| 163 | +} |
| 164 | + |
| 165 | +`} |
| 166 | + </CodeBlock> |
| 167 | + </TabItem> |
| 168 | +</Tabs> |
| 169 | +
|
| 170 | +:::tip |
| 171 | +
|
| 172 | +- You must add the generated **APP_URL** to the `app` capability in the config file. |
| 173 | +- You can generate capabilities for your test requirements with the help of our inbuilt [**Capabilities Generator tool**](https://www.lambdatest.com/capabilities-generator/).For more details, please refer to our guide on [**Desired Capabilities in Appium**](https://www.lambdatest.com/support/docs/desired-capabilities-in-appium/). |
| 174 | + |
| 175 | +::: |
| 176 | + |
0 commit comments