Skip to content

Files

Latest commit

7798dc7 · Mar 14, 2023

History

History
93 lines (64 loc) · 2.15 KB

flutter.md

File metadata and controls

93 lines (64 loc) · 2.15 KB

Flutter

Maestro supports Flutter.

Commands such as tapOn provide you with ways to select these widgets based on text or semantic labels.

Interacting with Widgets by Text

Maestro can interact with widgets that have some displayed text (data in the Text widget, hintText in the TextField).

Example: Tap on a InkWell widget

Given an InkWell widget with a Text widget child:

InkWell(
    child: const Text('Open Browser'),
    onTap: () => launch('')
)

The following command will tap on the InkWell widget:

- tapOn: "Open Browser"

Example: Tap on TextFormField

For the following widget:

TextFormField(
    decoration: const InputDecoration(
        border: UnderlineInputBorder(), 
        labelText: 'Enter your username'
    )
)

The following command will tap on the TextFormField:

- tapOn: "Enter your username"

Interacting with Widgets by semantic label

Views can be decorated with a Semantics widget that will attach a semantic label that in turn can be used to locate a view

Semantics(
    label: "My Label",
    child: SomeView()
)

SomeView can then be located using the label:

- tapOn: ".*My Label.*"

semanticLabel property

Some widgets can be interacted with via semanticLabel property directly. For the following widget:

FloatingActionButton(
   onPressed: _incrementCounter,
   child: const Icon(Icons.add, semanticLabel: "fabAddIcon"),
)

The following command will tap on the FloatingActionButton

- tapOn: "fabAddIcon"

{% content-ref url="broken-reference" %} Broken link {% endcontent-ref %}

Known Limitations

There are known limitations

  1. In cases where there are both semanticLabel and text label, the semanticLabel takes precedence. It's recommended to use maestro studio to identify accessibility labels.
  2. Interaction on the basis of key is currently not possible.
  3. Maestro cannot be used to test desktop or web apps (yet).