This repository contains a mobile automation testing framework built with WebdriverIO and Appium. It's designed to run automated tests on Android and iOS devices/emulators.
Before setting up the project, ensure you have the following installed:
- Node.js (v16 or higher)
- npm (v8 or higher)
- Java Development Kit (JDK 11 or higher)
- Android SDK (for Android testing)
- Android SDK Platform-tools
- Android Emulator
- Android SDK Build-tools
- Xcode (for iOS testing, macOS only)
- Appium 2.x
- Clone the repository
git clone <repository-url>
cd MobileQA
- Install dependencies:
npm install
├── apps/ # Mobile application binaries (.apk, .ipa)
│ └── android-538.apk # Android application under test
├── configs/ # WebdriverIO configuration files
│ └── wdio.android.conf.js # Android-specific configuration
├── test/ # Test files
│ ├── pageobjects/ # Page Object Models
│ │ ├── login.page.js # Login page object
│ │ ├── page.js # Base page object
│ │ └── secure.page.js # Secure page object
│ └── specs/ # Test specifications
│ └── test.e2e.js # E2E test example
├── .gitignore # Git ignore file
├── package.json # Project dependencies and scripts
└── wdio.conf.js # Main WebdriverIO configuration
In a separate terminal window, start the Appium server:
npm run appium
Ensure you have an Android emulator running or a physical device connected, then run:
npm run test:android
Ensure you have an iOS simulator running or a physical device connected, then run:
npm run test:ios
npm test
The Android configuration is defined in configs/wdio.android.conf.js
. Key settings include:
- Device Name:
Android GoogleAPI Emulator
- Platform Version:
12.0
- Automation Framework:
UiAutomator2
- App Path:
./apps/android-538.apk
Modify these settings to match your environment and requirements.
The iOS configuration would be defined in wdio.ios.conf.js
(not currently in the repository). You would need to create this file with appropriate iOS settings.
Tests are written using the WebdriverIO framework with Mocha as the test runner. The project uses the Page Object Model pattern for better maintainability.
const { expect } = require('@wdio/globals')
const LoginPage = require('../pageobjects/login.page')
const SecurePage = require('../pageobjects/secure.page')
describe('My Login application', () => {
it('should login with valid credentials', async () => {
await LoginPage.open()
await LoginPage.login('tomsmith', 'SuperSecretPassword!')
await expect(SecurePage.flashAlert).toBeExisting()
await expect(SecurePage.flashAlert).toHaveText(
expect.stringContaining('You logged into a secure area!'))
})
})
Page objects help organize selectors and methods for interacting with specific pages of your application.
const { $ } = require('@wdio/globals')
const Page = require('./page')
class LoginPage extends Page {
// Define selectors
get inputUsername () { return $('#username') }
get inputPassword () { return $('#password') }
get btnSubmit () { return $('button[type="submit"]') }
// Define methods
async login (username, password) {
await this.inputUsername.setValue(username)
await this.inputPassword.setValue(password)
await this.btnSubmit.click()
}
open () {
return super.open('login')
}
}
module.exports = new LoginPage()
-
Appium not found: Install Appium globally or locally in the project:
npm install --save-dev appium
-
Device not found: Ensure your emulator/simulator is running or physical device is connected and properly set up for development.
-
App installation fails: Check that the app path in the configuration is correct and the app is compatible with the device/emulator version.
-
Test fails to find elements: Verify the selectors in your page objects. Use Appium Inspector to help identify the correct selectors.
-
Increase log level in
wdio.conf.js
:logLevel: 'debug',
-
Use Appium Inspector to inspect the application's UI elements.
-
Add browser.debug() in your test to pause execution and inspect the state.
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin feature/your-feature-name
- Submit a pull request
ISC