AppiumTestDistribution / appium-flutter-integration-driver

MIT License
29 stars 10 forks source link

Support for Flutter semantic identifier to improve test scalability and maintainability #98

Open ReverseScale opened 2 hours ago

ReverseScale commented 2 hours ago

Description:

As Flutter apps grow, automated testing becomes increasingly challenging. Common issues include:

Multi-language support: Test scripts need to adapt to the language displayed in the app. Dynamic content: Non-static content, such as A/B tests, may cause inconsistencies in UI tests. Large-scale applications: The growing number of screens increases the complexity and difficulty of test maintenance. To address these challenges, Flutter introduced the semantic identifier feature, which helps uniquely identify UI elements independently of the content they display. This makes automated testing more robust and easier to maintain.

Why semantic identifier is important:

Language independence: Semantic identifiers do not rely on displayed text or labels, making tests more resilient to language changes and localization. Dynamic content readiness: Since semantic identifiers are static, even when UI content changes due to experiments (like A/B tests), the test scripts remain stable. Ease of maintenance: Using semantic identifiers reduces the need to frequently update tests when content or UI changes. Feature availability:

This feature is available starting from Flutter 3.19 (released on February 15th, 2024) in the stable channel. To use it, you need to upgrade to the latest stable Flutter release.

References:

Flutter Semantics Documentation Flutter 3.19 Release Notes

Request: Please add support for semantic identifier in appium-flutter-integration-driver to enable more robust and scalable testing for Flutter applications.

ReverseScale commented 2 hours ago

Example: Tap on a widget by semantics identifier

Semantics(
  identifier: 'signin_button',
  child: ElevatedButton(
    onPressed: _signIn,
    child: Text('Sign in'),
  ),
)
saikrishna321 commented 1 hour ago

@ReverseScale Have you tried

const loginButton = await browser.flutterBySemanticsLabel$('login_button');
await loginButton.click();