Template for end-to-end testing with hybrid mobile applications.
- Download and install Node.js (version 16.17 or higher).
- Install TypeScript (version 5 or higher).
- Install Visual Studio Code.
- Clone the GitHub project repository.
- Run
npm install
to install project dependencies.
- Create a
.env
file in the project root with the following variables:BROWSERSTACK_USERNAME
BROWSERSTACK_ACCESS_KEY
BROWSERSTACK_ANDROID_APP_ID
BROWSERSTACK_IOS_APP_ID
- Sign in to BrowserStack, upload your mobile app files (
.apk
for Android and.ipa
for iOS), and note the app IDs. - Update the
.env
file with your credentials and app IDs. - Run the Android tests with BrowserStack using:
npm run test:android:bs
To run Android tests on a Windows machine, ensure the following setup:
- Install the latest version of Java and set the
JAVA_HOME
environment variable to the JRE directory (e.g.,C:\Program Files\Android\Android Studio\jre\
). - Install Node.js version 16 or higher.
- Install the latest version of Android Studio.
- Add
ANDROID_HOME
to your system environment variables. - Install Appium globally:
npm install -g appium
- Download Appium Inspector (version 2 or higher).
- Install necessary Appium drivers:
appium driver install uiautomator2 appium driver install xcuitest
- Enable virtualization in BIOS (video tutorial).
- Connect an Android device to your computer with USB debugging enabled.
- Verify the device connection by running:
adb devices
- In the Android configuration file (
config/wdio.android.conf.js
), set theplatformVersion
,deviceName
, and the path to the.apk
file to match your connected Android device. - Start Appium:
appium
- Open Appium Inspector and connect it to your device to interact with your apps.
To run iOS tests with BrowserStack or locally, ensure the following setup:
- Install Xcode (version 12 or higher) from the Mac App Store.
- Configure Xcode Command Line Tools by selecting Xcode > Preferences > Locations and ensuring the Command Line Tools dropdown is set to the Xcode version.
- Install CocoaPods (if not already installed) for dependency management:
sudo gem install cocoapods
- Set up Appium for iOS testing:
npm install -g appium appium driver install xcuitest
- Connect an iOS device via USB and enable Developer Mode on the device (found in Settings > Privacy & Security > Developer Mode on iOS 16+).
- In the iOS configuration file (
config/wdio.ios.conf.js
), specifyplatformVersion
,deviceName
, and the path to the.ipa
file. - Start Appium server:
appium
- Use Appium Inspector to verify that the setup works and to locate UI elements on your iOS app.
- Ensure that the
.env
file containsBROWSERSTACK_IOS_APP_ID
along with your BrowserStack credentials (BROWSERSTACK_USERNAME
,BROWSERSTACK_ACCESS_KEY
). - Run iOS tests on BrowserStack with the following command:
npm run test:ios:bs
We use ESLint with the Prettier plugin to lint and auto-format TypeScript files. ESLint will auto-format code on every run.
All test cases should be organized within the test
folder. You can separate tests for different apps (e.g., msb-app
) and define generic classes with getters and setters to reuse logic across classes.
This project follows the Page Object Pattern as outlined in the WebdriverIO documentation. The main idea is to encapsulate page-specific logic into classes and utilize them in spec files to execute tests. For example, a LoginPage
class defines elements as attributes, allowing for easy reuse throughout the code.