appium flutter app 自动化测试

Appium FlutterDriver 简介

Appium Flutter Driver 是一个测试自动化工具,用于在多个平台/操作系统上运行Flutter应用程序

打包测试 App

开启flutterdriver扩展模式

Step1 在app源码 runApp()之前添加 enableFlutterDriverExtension()

void main() {
  enableFlutterDriverExtension();
  init();
  runApp(MyApp());
}

官方示例:appium-flutter-driver/main.dart at e57bd279bdda85e504406830f5c443f281241786 · appium-userland/appium-flutter-driver · GitHub

Step2 编译 app

  • flutter不支持release包,所以需要以debugprofile 模式编译

代码示例

启动参数

只需修改automationName 即可

automationName="flutter"

ps: 验证时发现 加不加都可以正常使用。。研究中~

Flutter Capabilities

Capability Description Example Values
appium:retryBackoffTime 等待 socket 连接重试获取 flutter session 的时间(默认 3000ms) 500
appium:maxRetryCount 获取 flutter session 连接重试次数(默认 30) 20
appium:observatoryWsUri The URL to attach to the Dart VM. The appium flutter driver finds the WebSocket URL from the device log by default. You can skip the finding the URL process by specifying this capability. Then, this driver attempt to establish a WebSocket connection against the given WebSocket URL. Note that this capability expects the URL is ready for access by outside an appium session. This flutter driver does not do port-forwarding with this capability. You may need to coordinate the port-forwarding as well. ‘ws://127.0.0.1:60992/aaaaaaaaaaa=/ws’
appium:skipPortForward Whether skip port forwarding from the flutter driver local to the device under test with observatoryWsUri capability. It helps you to manage the application under test, the observatory URL and the port forwarding configuration. The default is true. true, false

示例apk

https://github.com/appium-userland/appium-flutter-driver/blob/main/example/sample2/app-debug.apk