Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 8, 2025

This PR implements backdoor support in Plugin.Maui.UITestHelpers.Appium, enabling UI tests to invoke app methods directly without going through the UI, similar to Xamarin.UITest's backdoor functionality.

Overview

Backdoors allow tests to call methods in the app under test directly, which is useful for:

  • Setting up test data without complex UI navigation
  • Changing app state for specific test scenarios
  • Retrieving internal app information for assertions
  • Bypassing lengthy UI flows during test setup

Implementation

The implementation follows the existing architectural patterns in the codebase:

Core Interface

  • Added IBackdoorSupportedApp interface with Invoke() and Invoke<T>() methods
  • Comprehensive XML documentation explaining usage and return behavior

Extension Methods

  • app.Invoke(string methodName, params object[] args) for simple invocations
  • app.Invoke<T>(string methodName, params object[] args) for typed return values
  • Follows the same pattern as existing ScreenshotSupportedAppExtensions and LogsSupportedAppExtensions

Command Implementation

  • Created AppiumBackdoorActions command group using Appium's ExecuteScript with mobile: backdoor
  • Handles parameter marshaling and graceful error handling
  • Returns null/default values on failure rather than throwing exceptions

Integration

  • Updated AppiumApp to implement IBackdoorSupportedApp and register the new command group
  • Seamless integration with existing command execution infrastructure

Usage

// Simple method invocation
app.Invoke("SetupTestData");

// Method with parameters
app.Invoke("SetUserPreference", "theme", "dark");

// Typed return values
string currentUser = app.Invoke<string>("GetCurrentUser");
int itemCount = app.Invoke<int>("GetItemCount");

Documentation

  • Added comprehensive usage documentation in BACKDOOR_USAGE.md
  • Updated main README with feature overview and examples
  • Includes guidance for app-side implementation
  • Added test coverage demonstrating the functionality

App-Side Requirements

Apps need to implement a handler for the mobile: backdoor script execution to respond to backdoor calls. The documentation provides examples of how to set this up in a .NET MAUI application.

Fixes #26.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Feature Request: Backdoor support in Appium Add backdoor support for Appium UI tests Aug 8, 2025
@Copilot Copilot AI requested a review from jfversluis August 8, 2025 15:53
Copilot finished work on behalf of jfversluis August 8, 2025 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Backdoor support in Appium
2 participants