npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

my_appium-flutter-driver

v0.0.31

Published

Appium Flutter driver

Downloads

6

Readme

Appium Flutter Driver

Build Status Greenkeeper badge NPM version Downloads Dependency Status devDependency Status

Appium Flutter Driver is a test automation tool for Flutter apps on multiple platforms/OSes. Appium Flutter Driver is part of the Appium mobile test automation tool.

:warning: pre-0.1.x version

This package is in early stage of experiment, breaking changes and breaking codes are to be expected! All contributions, including non-code, are welcome! See TODO list below.

Flutter Driver vs Appium Flutter Driver

Even though Flutter comes with superb integration test support, Flutter Driver, it does not fit some specific use cases, such as

  • writing test in other languages than Dart
  • running integration test for Flutter app with embedded webview or native view, or existing native app with embedded Flutter view
  • running test on multiple devices simultaneously
  • running integration test on device farms, such as Sauce Labs, AWS, Firebase

Under the hood, Appium Flutter Driver use the Dart VM Service Protocol with extension ext.flutter.driver, similar to Flutter Driver, to control the Flutter app-under-test (AUT).

Installation

In order to use appium-flutter-driver, we need to use appium version 1.16.0 or higher

npm i -g appium-flutter-driver

Usage

If you are unfamiliar with running Appium tests, start with Appium Getting Starting first.

Your Flutter app-under-test (AUT) must be compiled in debug or profile mode, because Flutter Driver does not support running in release mode.. Also, ensure that your Flutter AUT has enableFlutterDriverExtension() before runApp.

This snippet, taken from example dir, is a script written as an appium client with webdriverio, and assumes you have appium server (with appium-flutter-driver installed) running on the same host and default port (4723). For more info, see example's README.md

Desired Capabilities for flutter driver only

| Capability | Description | Example Values | | - | - | -| | retryBackoffTime | the time wait for socket connection retry for get flutter session (default 300000ms)|500| | maxRetryCount | the count for socket connection retry for get flutter session (default 10) | 20|

const wdio = require('webdriverio');
const assert = require('assert');
const { byValueKey } = require('appium-flutter-finder');

const osSpecificOps = process.env.APPIUM_OS === 'android' ? {
  platformName: 'Android',
  deviceName: 'Pixel 2',
  // @todo support non-unix style path
  app: __dirname +  '/../apps/app-free-debug.apk',
}: process.env.APPIUM_OS === 'ios' ? {
  platformName: 'iOS',
  platformVersion: '12.2',
  deviceName: 'iPhone X',
  noReset: true,
  app: __dirname +  '/../apps/Runner.zip',

} : {};

const opts = {
  port: 4723,
  capabilities: {
    ...osSpecificOps,
    automationName: 'Flutter',
    retryBackoffTime: 500
  }
};

(async () => {
  const counterTextFinder = byValueKey('counter');
  const buttonFinder = byValueKey('increment');

  const driver = await wdio.remote(opts);

  if (process.env.APPIUM_OS === 'android') {
    await driver.switchContext('NATIVE_APP');
    await (await driver.$('~fab')).click();
    await driver.switchContext('FLUTTER');
  } else {
    console.log('Switching context to `NATIVE_APP` is currently only applicable to Android demo app.')
  }

  assert.strictEqual(await driver.getElementText(counterTextFinder), '0');

  await driver.elementClick(buttonFinder);
  await driver.touchAction({
    action: 'tap',
    element: { elementId: buttonFinder }
  });

  assert.strictEqual(await driver.getElementText(counterTextFinder), '2');

  driver.deleteSession();
})();

API

Legend:

| Icon | Description | | - | - | | :white_check_mark: | integrated to CI | | :ok: | manual tested without CI | | :warning: | availalbe without manual tested | | :x: | unavailable |

Finders

| Flutter Driver API | Status | WebDriver example | | - | - | - | | ancestor | :ok: | | | bySemanticsLabel | :ok: | | | byTooltip | :ok: | byTooltip('Increment') | | byType | :ok: | byType('TextField') | | byValueKey | :ok: | byValueKey('counter') | | descendant | :ok: | | | pageBack | :ok: | pageBack() | | text | :ok: | byText('foo') |

Commands

| Flutter API | Status | WebDriver example | Scope | | - | - | - | - | | FlutterDriver.connectedTo | :ok: | wdio.remote(opts) | Session | | checkHealth | :ok: | driver.execute('flutter:checkHealth') | Session | | clearTextbox | :ok: | driver.elementClear(find.byType('TextField')) | Session | | clearTimeline | :ok: | driver.execute('flutter:clearTimeline') | Session | | close | :ok: | driver.deleteSession() | Session | | enterText | :ok: | driver.elementSendKeys(find.byType('TextField'), 'I can enter text') (no focus required) driver.elementClick(find.byType('TextField')); driver.execute('flutter:enterText', 'I can enter text') (focus required by tap/click first) | Session | | forceGC | :ok: | driver.execute('flutter:forceGC') | Session | | getBottomLeft | :ok: | driver.execute('flutter:getBottomLeft', buttonFinder) | Widget | | getBottomRight | :ok: | driver.execute('flutter:getBottomRight', buttonFinder) | Widget | | getCenter | :ok: | driver.execute('flutter:getCenter', buttonFinder) | Widget | | getRenderObjectDiagnostics | :ok: | driver.execute('flutter:getRenderObjectDiagnostics', counterTextFinder) | Widget | | getRenderTree | :ok: | driver.execute('flutter: getRenderTree') | Session | | getSemanticsId | :ok: | driver.execute('flutter:getSemanticsId', counterTextFinder) | Widget | | getText | :ok: | driver.getElementText(counterTextFinder) | Widget | | getTopLeft | :ok: | driver.execute('flutter:getTopLeft', buttonFinder) | Widget | | getTopRight | :ok: | driver.execute('flutter:getTopRight', buttonFinder) | Widget | | getVmFlags | :x: | | Session | | getWidgetDiagnostics | :x: | | Widget | | requestData | :ok: | driver.execute('flutter:requestData', json.dumps({"deepLink": "myapp://item/id1"})) | Session | | runUnsynchronized | :x: | | Session | | setFrameSync |:ok:| driver.execute('flutter:setFrameSync', bool , durationMilliseconds)| Session | | screenshot | :ok: | driver.takeScreenshot() | Session | | screenshot | :ok: | driver.saveScreenshot('a.png') | Session | | scroll | :ok: | driver.execute('flutter:scroll', find.byType('ListView'), {dx: 50, dy: -100, durationMilliseconds: 200, frequency: 30}) | Widget | | scrollIntoView | :ok: | driver.execute('flutter:scrollIntoView', find.byType('TextField'), {alignment: 0.1}) | Widget | | scrollUntilVisible | :ok: | driver.execute('flutter:scrollUntilVisible', find.byType('ListView'), {item:find.byType('TextField'), dxScroll: 90, dyScroll: -400}); | Widget | | setSemantics | :x: | | Session | | setTextEntryEmulation | :x: | | Session | | startTracing | :x: | | Session | | stopTracingAndDownloadTimeline | :x: | | Session | | tap | :ok: | driver.elementClick(buttonFinder) | Widget | | tap | :ok: | driver.touchAction({action: 'tap', element: {elementId: buttonFinder}}) | Widget | | traceAction | :x: | | Session | | waitFor | :ok: | driver.execute('flutter:waitFor', buttonFinder, {durationMilliseconds: 100}) | Widget | | waitForAbsent | :ok: | driver.execute('flutter:waitForAbsent', buttonFinder) | Widget | | waitUntilNoTransientCallbacks | :x: | | Widget | | :question: | :ok: | setContext | Appium | | :question: | :warning: | getCurrentContext | Appium | | :question: | :warning: | getContexts | Appium | | :question: | :x: | longTap | Widget |

TODO

  • [ ] iOS Real device
  • [ ] CI (unit test / integration test with demo app)
  • [ ] CD (automatic publish to npm)
  • [x] finder as a seperate package
  • [ ] switching context between Flutter and AndroidView
  • [ ] switching context between Flutter and UiKitView
  • [ ] switching context between Flutter and webview
  • [ ] Flutter-version-aware API
  • [ ] Error handling

Test Status

Saucelabs Test Status

Powered by Saucelabs