Skip to content

jbcrane13/appium-multiplatform-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Appium Multi-Platform Automation Framework

Python Appium iOS Android License

A professional, reusable automation framework that creates independent test automation projects for iOS and Android mobile applications.

Features โ€ข Quick Start โ€ข Documentation โ€ข Examples โ€ข Contributing


๐ŸŽฏ Overview

This framework solves a critical problem in mobile test automation: reusability without code duplication.

Instead of creating a framework tied to a single app (or duplicating code for each new app), this framework acts as a template system that deploys complete, independent automation projects for unlimited applications.

The Problem This Solves

Traditional Approach:

โŒ Framework tied to one app
โŒ Duplicate entire framework for each new app
โŒ Maintenance nightmare with N copies
โŒ Manual setup for each project
โŒ No platform abstraction

This Framework:

โœ… One reusable template โ†’ unlimited apps
โœ… Each deployment creates independent project
โœ… Single source of truth for framework updates
โœ… Automated deployment with one command
โœ… Built for iOS and Android from day one

โœจ Features

๐Ÿš€ Automated Deployment

  • One-command project creation - Deploy complete automation project in < 2 minutes
  • Validates prerequisites - Checks for Appium, Xcode/Android SDK, Python
  • Builds apps automatically - Compiles iOS apps (or Android APKs when implemented)
  • Extracts metadata - Bundle ID (iOS), Package name (Android)
  • Generates starter code - Page objects, tests, configurations

๐ŸŒ Multi-Platform Architecture

  • iOS (XCUITest) - โœ… Fully implemented and production-ready
  • Android (UIAutomator2) - ๐Ÿšง Architecture ready, implementation planned
  • Platform-agnostic base classes - Write once, run on both (future)
  • Cross-platform test support - Shared test scenarios when applicable

๐Ÿ—๏ธ Professional Architecture

  • Page Object Model (POM) - Clean separation of test logic and UI
  • Platform abstraction - Base classes handle platform differences
  • Pytest-based - Industry-standard test framework
  • Type hints throughout - Modern Python 3.8+ practices
  • Comprehensive error handling - Clear, actionable error messages

๐Ÿ“Š Testing Capabilities

  • Performance optimized - 40-60% faster execution with configurable wait times
  • Fast mode - Enable via FAST_MODE=true for rapid development cycles
  • Parallel execution - pytest-xdist for concurrent test runs
  • Robust element finding - Multi-strategy fallback for iOS sheet/modal handling
  • Diagnostic tools - Built-in utilities for troubleshooting test failures
  • Multiple locator strategies - Accessibility ID, XPath, iOS Predicates, Class Chains
  • Smart wait mechanisms - Configurable, context-aware wait times
  • Screenshot on failure - Automatic capture with clear naming
  • HTML & Allure reports - Professional test reporting
  • Pytest markers - Organize tests by platform, suite, feature

๐Ÿ”ง Developer Experience

  • Colored terminal output - Clear, readable deployment messages
  • Verbose mode - Debug deployment issues easily
  • Flexible configuration - JSON-based capabilities, environment variables
  • Virtual environment management - Isolated dependencies per project
  • Comprehensive documentation - Guides, examples, troubleshooting

๐Ÿš€ Quick Start

Prerequisites

# Required
โœ… Python 3.8+
โœ… Node.js & npm
โœ… Appium 2.x

# For iOS
โœ… Xcode 14.0+
โœ… iOS Simulators
โœ… XCUITest driver

# For Android (when implemented)
โœ… Android Studio
โœ… Android SDK
โœ… Android Emulator
โœ… UIAutomator2 driver

Installation

# Install Appium
npm install -g appium

# Install iOS driver
appium driver install xcuitest

# Clone this repository
git clone https://github.com/jbcrane13/appium-multiplatform-framework.git
cd appium-multiplatform-framework

# Install framework dependencies (optional, for development)
pip install -r requirements.txt

Deploy to Your App

# Deploy iOS automation project
python deploy/deploy_ios.py --app-path ~/Projects/YourApp

# This creates: ~/Projects/YourApp-Automation/

Run Tests

# Navigate to deployed project
cd ~/Projects/YourApp-Automation

# Set up virtual environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Start Appium (separate terminal)
appium

# Run smoke tests
pytest tests/ios/ -m smoke -v

# Run all tests
pytest tests/ios/ -v

# Generate HTML report
pytest tests/ios/ --html=reports/ios/report.html

๐Ÿ“ Repository Structure

appium-multiplatform-framework/
โ”œโ”€โ”€ deploy/                          # ๐Ÿš€ Deployment Scripts
โ”‚   โ”œโ”€โ”€ deploy_ios.py               # iOS deployment (READY)
โ”‚   โ”œโ”€โ”€ deploy_android.py           # Android deployment (COMING SOON)
โ”‚   โ”œโ”€โ”€ deploy_both.py              # Multi-platform orchestrator
โ”‚   โ””โ”€โ”€ common.py                   # Shared deployment utilities
โ”‚
โ”œโ”€โ”€ templates/                       # ๐Ÿ“‹ Project Templates
โ”‚   โ”œโ”€โ”€ common/                     # Shared templates
โ”‚   โ”‚   โ”œโ”€โ”€ pytest.ini.template
โ”‚   โ”‚   โ”œโ”€โ”€ requirements.txt.template
โ”‚   โ”‚   โ””โ”€โ”€ gitignore.template
โ”‚   โ”œโ”€โ”€ ios/                        # iOS-specific templates
โ”‚   โ”‚   โ”œโ”€โ”€ base_page.py.template
โ”‚   โ”‚   โ”œโ”€โ”€ conftest.py.template
โ”‚   โ”‚   โ”œโ”€โ”€ test_smoke.py.template
โ”‚   โ”‚   โ””โ”€โ”€ capabilities.json.template
โ”‚   โ””โ”€โ”€ android/                    # Android templates (future)
โ”‚       โ””โ”€โ”€ README.md
โ”‚
โ”œโ”€โ”€ examples/                        # ๐Ÿ’ก Usage Examples
โ”‚   โ””โ”€โ”€ github-actions-multiplatform.yml
โ”‚
โ”œโ”€โ”€ docs/                           # ๐Ÿ“š Documentation
โ”‚   โ””โ”€โ”€ (additional documentation)
โ”‚
โ”œโ”€โ”€ README.md                        # This file
โ”œโ”€โ”€ QUICKSTART.md                    # 5-minute getting started guide
โ”œโ”€โ”€ FRAMEWORK_SUMMARY.md             # Detailed framework overview
โ”œโ”€โ”€ CHANGELOG.md                     # Version history
โ””โ”€โ”€ requirements.txt                 # Framework dependencies

๐Ÿ“ฆ What Gets Deployed

When you run deploy_ios.py, a complete automation project is created:

YourApp-Automation/
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ ios/
โ”‚   โ”‚   โ””โ”€โ”€ capabilities.json       # โœ… iOS device configurations
โ”‚   โ”œโ”€โ”€ android/                    # ๐Ÿšง Ready for Android
โ”‚   โ””โ”€โ”€ common.json                 # Shared settings
โ”‚
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ ios/
โ”‚   โ”‚   โ”œโ”€โ”€ conftest.py            # iOS pytest fixtures
โ”‚   โ”‚   โ””โ”€โ”€ test_smoke.py          # โœ… Ready-to-run smoke tests
โ”‚   โ”œโ”€โ”€ android/                    # ๐Ÿšง Placeholder
โ”‚   โ””โ”€โ”€ cross_platform/             # ๐Ÿšง Cross-platform tests
โ”‚
โ”œโ”€โ”€ pages/
โ”‚   โ”œโ”€โ”€ base_page.py               # โœ… Platform-agnostic base (480+ lines)
โ”‚   โ”œโ”€โ”€ ios/
โ”‚   โ”‚   โ””โ”€โ”€ home_page.py           # iOS page object example
โ”‚   โ””โ”€โ”€ android/                    # ๐Ÿšง Placeholder
โ”‚
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ debug_helpers.py           # โœ… Diagnostic utilities (page source, element inspection)
โ”‚   โ””โ”€โ”€ wait_helper.py             # โœ… Configurable wait time management
โ”œโ”€โ”€ data/                           # Test data files
โ”œโ”€โ”€ reports/                        # Test reports (ios/, android/)
โ”œโ”€โ”€ screenshots/                    # Failure screenshots (ios/, android/)
โ”œโ”€โ”€ logs/                           # Test execution logs
โ”œโ”€โ”€ debug/                          # Debug output (page source XML)
โ”‚
โ”œโ”€โ”€ venv/                           # Virtual environment (auto-created)
โ”œโ”€โ”€ pytest.ini                      # โœ… Configured with markers
โ”œโ”€โ”€ requirements.txt                # โœ… All dependencies
โ”œโ”€โ”€ .gitignore                      # โœ… Proper ignores
โ”œโ”€โ”€ README.md                       # โœ… Project-specific docs
โ”œโ”€โ”€ TROUBLESHOOTING.md              # โœ… Diagnostic workflow guide
โ”œโ”€โ”€ CLAUDE.md                       # โœ… AI development guidelines
โ””โ”€โ”€ README_PERFORMANCE.md           # โœ… Performance optimization guide

Everything you need to start testing immediately!


๐Ÿ’ป Usage Examples

Basic Deployment

# Deploy to iOS app
python deploy/deploy_ios.py --app-path ~/Projects/AppJubilee

# Creates: ~/Projects/AppJubilee-Automation/

Advanced Options

# Custom output directory
python deploy/deploy_ios.py \
  --app-path ~/Projects/MyApp \
  --output-dir ~/Automation

# Override app name
python deploy/deploy_ios.py \
  --app-path ~/Projects/MyApp \
  --app-name "CoolApp"

# Skip building (use existing .app)
python deploy/deploy_ios.py \
  --app-path ~/Projects/MyApp \
  --skip-build

# Skip virtual environment
python deploy/deploy_ios.py \
  --app-path ~/Projects/MyApp \
  --skip-venv

# Verbose output for debugging
python deploy/deploy_ios.py \
  --app-path ~/Projects/MyApp \
  --verbose

Deploy Multiple Apps

# The framework is reusable!
python deploy/deploy_ios.py --app-path ~/Projects/App1  # โ†’ App1-Automation/
python deploy/deploy_ios.py --app-path ~/Projects/App2  # โ†’ App2-Automation/
python deploy/deploy_ios.py --app-path ~/Work/App3     # โ†’ App3-Automation/

# Each project is independent and isolated

Running Tests

# In your deployed project
cd ~/Projects/YourApp-Automation

# Activate virtual environment
source venv/bin/activate

# Run smoke tests
pytest tests/ios/ -m smoke -v

# Run all iOS tests
pytest tests/ios/ -v

# Run with HTML report
pytest tests/ios/ --html=reports/ios/report.html --self-contained-html

# Run in parallel (requires pytest-xdist)
pytest tests/ios/ -n auto

# Run specific test
pytest tests/ios/test_smoke.py::TestiOSSmoke::test_app_launches -v

# Run with different markers
pytest tests/ios/ -m "smoke or functional" -v

โšก Performance Optimization

Fast Mode (50% faster execution):

# Enable via environment variable
FAST_MODE=true pytest tests/ios/ -v

# Or edit config/common.json and set "fast_mode": { "enabled": true }

Parallel Execution (60-70% faster):

# Install pytest-xdist
pip install pytest-xdist

# Run with auto-detected workers
pytest tests/ios/ -n auto

# Or specify worker count
pytest tests/ios/ -n 2

Time Savings:

  • Standard Mode: ~40% faster (optimized wait times)
  • Fast Mode: ~50% faster (minimal wait times)
  • Parallel Mode: ~60-70% faster (concurrent execution)

See README_PERFORMANCE.md in your deployed project for detailed optimization guide.

๐Ÿ” Diagnostic Tools

When tests fail, use built-in diagnostic utilities:

# Run diagnostic tests to inspect app state
pytest tests/ios/test_diagnostic.py -v -s

# Available diagnostics:
# - test_dump_page_source: Saves complete XML to debug/
# - test_find_tab_bar_elements: Prints tab structure
# - test_print_all_buttons: Lists all clickable elements
# - test_try_navigation_strategies: Tests navigation methods

Debug workflow:

  1. Check screenshot in screenshots/ios/
  2. Run test_dump_page_source to save XML
  3. Inspect debug/*.xml for element structure
  4. Update locators based on findings

See TROUBLESHOOTING.md in your deployed project for complete diagnostic workflow.


๐ŸŽจ Platform Abstraction

The framework is designed for multi-platform from day one:

Platform-Agnostic Base Page

# All page objects inherit from this
class BasePage:
    def __init__(self, driver):
        self.driver = driver
        self.platform = driver.capabilities['platformName'].lower()

    # Methods that work on both iOS and Android
    def find_element(self, locator):
        return self.driver.find_element(*locator)

    # Platform-specific methods
    def by_ios_predicate(self, predicate):
        if self.platform != 'ios':
            raise ValueError("iOS predicates only work on iOS")
        return ('-ios predicate string', predicate)

    def by_android_uiautomator(self, uia_string):
        if self.platform != 'android':
            raise ValueError("UIAutomator only works on Android")
        return ('-android uiautomator', uia_string)

Cross-Platform Tests (Future)

@pytest.mark.cross_platform
def test_login(driver):
    """This test will run on both iOS and Android."""
    login_page = LoginPage(driver)  # Works on both platforms
    login_page.login("user@example.com", "password")

    home_page = HomePage(driver)
    assert home_page.is_displayed()

๐Ÿ“Š Pytest Markers

Tests are organized with markers for flexible execution:

@pytest.mark.ios          # iOS platform
@pytest.mark.android      # Android platform
@pytest.mark.cross_platform  # Both platforms
@pytest.mark.smoke        # Smoke test suite
@pytest.mark.functional   # Functional tests
@pytest.mark.regression   # Full regression

Run specific subsets:

pytest tests/ -m smoke              # Smoke tests only
pytest tests/ -m "ios and smoke"    # iOS smoke tests
pytest tests/ -m functional         # Functional tests
pytest tests/ -m "not slow"         # Exclude slow tests

๐Ÿ”ง Configuration

Device Capabilities (JSON-based)

Easy to add new devices - just edit JSON:

{
  "iPhone_15_Pro": {
    "platformName": "iOS",
    "appium:platformVersion": "17.0",
    "appium:deviceName": "iPhone 15 Pro",
    "appium:automationName": "XCUITest",
    "appium:app": "/path/to/app.app",
    "appium:bundleId": "com.company.app"
  }
}

Common Configuration

{
  "app_name": "YourApp",
  "appium_url": "http://127.0.0.1:4723",
  "implicit_wait": 10,
  "explicit_wait": 30,
  "screenshot_on_failure": true,
  "log_level": "INFO",
  "wait_times": {
    "after_navigation": 0.2,
    "after_modal_dismiss": 0.1,
    "after_gesture": 0.1,
    "app_launch": 0.5
  },
  "fast_mode": {
    "enabled": false,
    "after_navigation": 0.1,
    "after_modal_dismiss": 0.05,
    "after_gesture": 0.05,
    "app_launch": 0.2
  }
}

Performance tuning:

  • Adjust wait_times for your app's performance characteristics
  • Enable fast_mode for rapid development cycles
  • Use environment variable FAST_MODE=true to override config

๐Ÿ“š Documentation


๐ŸŽ“ Examples

Example 1: iOS Smoke Test

@pytest.mark.ios
@pytest.mark.smoke
class TestiOSSmoke:
    def test_app_launches(self, driver):
        """Test that app launches successfully."""
        page_source = driver.page_source
        assert page_source is not None
        assert len(page_source) > 0

Example 2: Page Object

class HomePage(BasePage):
    @property
    def welcome_text_locator(self):
        return self.by_accessibility_id("welcome_text")

    def get_welcome_message(self):
        return self.get_text(self.welcome_text_locator)

    def is_displayed(self):
        return self.is_element_visible(self.welcome_text_locator)

Example 3: CI/CD Integration

See examples/github-actions-multiplatform.yml for a complete GitHub Actions workflow.


๐Ÿ› ๏ธ Development

Extending the Framework

The framework is designed to be extended:

Add new page objects:

# In your deployed project
pages/ios/my_new_page.py

Add new test suites:

# In your deployed project
tests/ios/test_my_feature.py

Add utilities:

# In your deployed project
utils/my_helper.py

Add test data:

# In your deployed project
data/my_test_data.json

Contributing to the Framework

See CONTRIBUTING.md for guidelines on:

  • Adding new features
  • Improving deployment scripts
  • Creating new templates
  • Adding Android support
  • Improving documentation

๐Ÿ—บ๏ธ Roadmap

Current Status

  • โœ… iOS Support - Fully implemented with robust element finding
  • โœ… Performance Optimization - 40-60% faster execution
  • โœ… iOS Sheet Handling - Multi-strategy dismissal for modals/sheets
  • โœ… Diagnostic Tools - Built-in troubleshooting utilities
  • โœ… Deployment Automation - Complete with best practices
  • โœ… Multi-platform Architecture - Ready for Android
  • โœ… Documentation - Comprehensive (includes performance & troubleshooting)
  • โœ… CI/CD Examples - Provided

Planned

  • ๐Ÿšง Android Support - Architecture ready, implementation planned

    • UIAutomator2 driver integration
    • Android page objects
    • Cross-platform test examples
  • ๐Ÿ”ฎ Future Enhancements

    • Data-driven testing utilities
    • API testing integration
    • Visual regression testing
    • Performance testing support
    • Cloud platform integration (BrowserStack, Sauce Labs)
    • Advanced reporting dashboards
    • Test data factories

๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

Areas for Contribution

  1. Android Implementation - Help implement deploy_android.py
  2. Template Improvements - Enhance existing templates
  3. Documentation - Improve guides, add examples
  4. Bug Fixes - Report and fix issues
  5. Features - Propose and implement new capabilities

How to Contribute

# 1. Fork the repository
# 2. Create a feature branch
git checkout -b feature/amazing-feature

# 3. Make your changes
# 4. Test thoroughly
# 5. Commit with clear messages
git commit -m "Add amazing feature"

# 6. Push to your fork
git push origin feature/amazing-feature

# 7. Open a Pull Request

๐Ÿ“‹ Requirements

Framework Requirements

  • Python 3.8+
  • Appium 2.x
  • Node.js & npm

Platform-Specific Requirements

iOS:

  • macOS
  • Xcode 14.0+
  • iOS Simulators
  • XCUITest driver: appium driver install xcuitest

Android (when implemented):

  • Android Studio
  • Android SDK (API 28+)
  • Android Emulator or physical device
  • UIAutomator2 driver: appium driver install uiautomator2

๐Ÿ› Troubleshooting

Common Issues

"Appium not found"

npm install -g appium
appium --version

"XCUITest driver not installed"

appium driver install xcuitest
appium driver list

"Build failed"

  • Open project in Xcode and build manually
  • Or use --skip-build and provide .app path

"Tests fail to run"

  • Ensure Appium server is running: appium
  • Check app path in config/ios/capabilities.json
  • Verify bundle ID is correct

"Element not found"

  1. Run diagnostic tests: pytest tests/ios/test_diagnostic.py::TestDiagnostic::test_dump_page_source -v -s
  2. Check XML in debug/ folder for actual element structure
  3. Update locators to match actual app state
  4. Use robust multi-strategy element finding (see CLAUDE.md)

"iOS sheet/modal blocking navigation"

  • Framework includes automatic sheet dismissal via swipe-down gesture
  • Use dismiss_modal_if_present(), dismiss_sheet_by_swipe(), or tap_outside_sheet()
  • See TROUBLESHOOTING.md for complete diagnostic workflow

"Tests are too slow"

  • Enable Fast Mode: FAST_MODE=true pytest tests/ios/ -v
  • Use parallel execution: pytest tests/ios/ -n auto
  • See README_PERFORMANCE.md for optimization strategies

For complete troubleshooting workflow, see TROUBLESHOOTING.md in deployed projects.


๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • Appium - For the excellent mobile automation framework
  • Pytest - For the robust testing framework
  • Python Community - For amazing tools and libraries

๐Ÿ“ž Support


๐ŸŒŸ Star History

If you find this framework useful, please consider giving it a star! โญ


๐Ÿ“ˆ Project Stats

GitHub stars GitHub forks GitHub issues GitHub pull requests


Built with โค๏ธ for the mobile test automation community

โฌ† back to top

About

Multiplatform Automation framework for iOS and Android App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages