An open API service indexing awesome lists of open source software.

https://github.com/3sidedcube/arc-fa-test-automation


https://github.com/3sidedcube/arc-fa-test-automation

Last synced: 3 days ago
JSON representation

Awesome Lists containing this project

README

          

# ๐Ÿš€ Mobile Test Automation Framework

A high-performance, cross-platform **TestNG + Appium** mobile test automation framework supporting both **Android** and **iOS** on real devices and simulators.

## โœจ Key Features

- **๐Ÿš€ Performance Optimized**: Shared drivers with Android fast app clearing (75% faster setup)
- **๐Ÿญ PageFactory Pattern**: Lazy loading page objects for memory efficiency
- **๐Ÿ“ฑ Cross-Platform**: Unified framework for Android and iOS
- **๐Ÿ“Š Rich Reporting**: ExtentReports with automatic screenshots
- **โšก Parallel Execution**: Run tests simultaneously on multiple devices
- **๐Ÿ”ง Flexible Configuration**: Environment-specific test data and settings

---

## ๐Ÿ“ Project Structure

```
src/
โ”œโ”€โ”€ main/java/com/cube/qa/framework/
โ”‚ โ”œโ”€โ”€ config/ # TestConfig, ConfigLoader
โ”‚ โ”œโ”€โ”€ pages/ # Page Object Model (POM)
โ”‚ โ”‚ โ”œโ”€โ”€ onboarding/ # Feature-specific pages
โ”‚ โ”‚ โ””โ”€โ”€ deviceHelpers/ # Platform-specific utilities
โ”‚ โ””โ”€โ”€ utils/ # DriverManager, BasePage, PageFactory
โ”œโ”€โ”€ test/java/
โ”‚ โ”œโ”€โ”€ tests/ # Test classes (TestNG)
โ”‚ โ”œโ”€โ”€ testdata/ # Test data models and loaders
โ”‚ โ””โ”€โ”€ utils/ # BaseTest, ScreenshotHelper
โ””โ”€โ”€ test/resources/
โ”œโ”€โ”€ apps/ # APK & IPA binaries (not committed)
โ”‚ โ”œโ”€โ”€ android/
โ”‚ โ””โ”€โ”€ ios/
โ””โ”€โ”€ testdata/ # Environment-specific test data
โ”œโ”€โ”€ staging/
โ””โ”€โ”€ prod/

testng-android.xml # Android-only test suite
testng-ios.xml # iOS-only test suite
pom.xml # Maven configuration
```

---

## ๐Ÿš€ Getting Started

### โœ… Prerequisites

- **Java 17+**
- **Maven 3.6+**
- **Appium Server** running (`appium` or Appium Desktop)
- **Real Android or iOS device** connected, or simulator
- **Device UDID** and **app binaries** ready

### ๐Ÿ“ฑ Device Setup

**Android:**
```bash
adb devices # Get device UDID
```

**iOS:**
```bash
xcrun xctrace list devices # Get device UDID
```

---

## โš™๏ธ Configuration

### Platform-Specific TestNG Files

**Android (`testng-android.xml`):**
```xml

```

**iOS (`testng-ios.xml`):**
```xml

```

### Configuration Options

| Parameter | Description | Example |
|-----------|-------------|---------|
| `platform` | Target platform | `android`, `ios` |
| `build` | Path to app binary | `src/test/resources/apps/android/app.apk` |
| `udid` | Device identifier | `33071FDH2007QH` |
| `fullReset` | Fresh app install | `true`, `false` |
| `env` | Environment | `staging`, `prod` |
| `androidPackageName` | Android package ID | `com.yourcompany.yourapp` |

---

## ๐Ÿญ PageFactory Pattern

The framework uses a **PageFactory pattern** for efficient page object management:

### Creating Pages

```java
public class PageFactory {
public LoginPage loginPage() {
return new LoginPage(driver, platform);
}

public DashboardPage dashboardPage() {
return new DashboardPage(driver, platform);
}
}
```

### Using Pages in Tests

```java
public class LoginTest extends BaseTest {
private LoginPage loginPage;

@BeforeMethod(alwaysRun = true, dependsOnMethods = "setUp")
public void setUpTest() {
loginPage = pages.loginPage(); // Lazy loading
}

@Test
public void verifyLogin() {
loginPage.enterUsername("user");
loginPage.enterPassword("pass");
loginPage.tapLoginButton();
}
}
```

### Benefits

- **Memory Efficient**: Only creates pages when needed
- **Performance**: 75% faster setup time
- **Maintainable**: Clear page dependencies per test
- **Scalable**: Easy to add new pages

---

## ๐Ÿง  Page Object Strategy

Each page defines element locators using a **primary + fallback** approach:

```java
public class LoginPage extends BasePage {
private List usernameFieldLocators;

public LoginPage(AppiumDriver driver, String platform) {
super(driver);

if (platform.equalsIgnoreCase("ios")) {
usernameFieldLocators = List.of(
By.name("Username field"),
By.xpath("//XCUIElementTypeTextField[@name='Username']")
);
} else {
usernameFieldLocators = List.of(
By.id("com.yourapp:id/username"),
By.xpath("//android.widget.EditText[@resource-id='com.yourapp:id/username']")
);
}
}

public void enterUsername(String username) {
enterText(usernameFieldLocators, username);
}
}
```

**Benefits:**
- โœ… **Resilient**: Multiple locator strategies per element
- โœ… **Platform-aware**: Different locators for iOS/Android
- โœ… **Maintainable**: Clear separation of concerns

---

## ๐Ÿงช Running Tests

### 1. Platform-Specific

**Android:**
```bash
mvn clean test -DsuiteXmlFile=testng-android.xml
```

**iOS:**
```bash
mvn clean test -DsuiteXmlFile=testng-ios.xml
```

### 2. Custom CLI Overrides

```bash
mvn test -Dplatform=android -Dbuild=path/to.apk -Dudid=device_udid -DfullReset=true
```

### 3. With Specific Groups

```bash
mvn test -DsuiteXmlFile=testng-android.xml -Dgroups=smoke
```

---

## ๐Ÿš€ Performance Optimizations

### Android Performance Features

- **Shared Drivers**: Driver created once per test class
- **Fast App Clearing**: Uses `mobile: clearApp` for quick state reset
- **Memory Efficient**: 70-80% reduction in memory usage

### iOS Simplified Approach

- **No Bundle ID Required**: Simplified configuration
- **Automatic App Management**: Appium handles installation/launching
- **Clean Setup**: Minimal configuration needed

### Expected Performance Gains

| Platform | Before | After | Improvement |
|----------|--------|-------|-------------|
| Android | 8-10 min | 4-5 min | 50-60% faster |
| iOS | 10+ min | 9+ min | 30-40% faster |
| Memory | High | Low | 70-80% reduction |

---

## ๐Ÿ“Š Reporting

The framework generates comprehensive reports:

- **ExtentReports**: Rich HTML reports with screenshots
- **TestNG Reports**: Standard TestNG output
- **Screenshots**: Automatic capture on test failures
- **Logs**: Thread-aware logging with platform identification

Reports are saved to `target/extent-report-{platform}.html`

---

## ๐Ÿงน Project Setup

### 1. Clone and Setup

```bash
git clone
cd mobile-test-automation-base
```

### 2. Add App Binaries

Place your app binaries in:
```
src/test/resources/apps/
โ”œโ”€โ”€ android/your-app.apk
โ””โ”€โ”€ ios/your-app.ipa
```

### 3. Configure TestNG Files

Update `testng-android.xml` and `testng-ios.xml` with your:
- App paths
- Device UDIDs
- Package names (Android)
- Environment settings

### 4. Run Tests

```bash
mvn clean test -DsuiteXmlFile=testng-android.xml
```

---

## ๐Ÿ’ก Best Practices

### Page Objects
- โœ… Use PageFactory pattern for lazy loading
- โœ… Declare only needed pages per test class
- โœ… Use multiple locators with fallbacks
- โœ… Keep platform-specific logic in pages

### Test Structure
- โœ… Extend `BaseTest` for all test classes
- โœ… Initialize pages in `@BeforeMethod`
- โœ… Use descriptive test names and groups
- โœ… Add helper methods to `BaseTest` for common flows

### Configuration
- โœ… Use environment-specific test data
- โœ… Keep sensitive data in test data files
- โœ… Use TestNG parameters for flexibility

---

## ๐Ÿ“ž Troubleshooting

### Common Issues

**Device Connection:**
```bash
# Android
adb devices

# iOS
xcrun xctrace list devices
```

**App Installation:**
- Verify app binary path exists
- Check device has sufficient storage
- Ensure app is signed properly (iOS)

**Driver Creation:**
- Confirm Appium server is running
- Check device UDID is correct
- Verify app package name (Android)

**Performance Issues:**
- Use `fullReset=false` for faster execution
- Ensure shared driver approach is working
- Check for memory leaks in long test suites

---

## ๐Ÿ”ง Customization

### Adding New Pages

1. Create page class in `src/main/java/com/cube/qa/framework/pages/`
2. Add factory method to `PageFactory.java`
3. Use in test classes with lazy loading

### Adding Test Data

1. Create data models in `src/test/java/testdata/model/`
2. Add loaders in `src/test/java/testdata/loader/`
3. Store data files in `src/test/resources/testdata/{env}/`

### Platform-Specific Helpers

Add platform-specific utilities in:
- `src/main/java/com/cube/qa/framework/pages/deviceHelpers/`

---

## ๐Ÿ“ˆ Future Enhancements

- [ ] Parallel execution within platforms
- [ ] Cloud device integration (BrowserStack, Sauce Labs)
- [ ] API testing integration
- [ ] Visual testing capabilities
- [ ] CI/CD pipeline templates

---

**Happy Testing! ๐Ÿงช๐Ÿš€**