Framework for Mobile test automation (Native app and Browser) on Android devices 📱
- Install Java JDK11 and Eclipse IDE
- Install NodeJS
- Install Android studio
- Install Appium Server using npm (CLI) command
npm install -g appium
. Appium server version 2.12.1
Command to check the installed appium version: `appium --version`
- Add below Android SDK path in the environment variable
- ANDROID_HOME = <path to Sdk folder>
- %ANDROID_HOME%\tools
- %ANDROID_HOME%\tools\bin
- %ANDROID_HOME%\platform-tools
- Install Appium Inspector
- Open Android Studio.
- Click on Tools -> AVD Manager -> Create Virtual Device -> Select the device and OS version -> Finish.
- Once Virtual device is created, click on Launch this AVD in the emulator.
- Command to view the list of devices attached
adb devices
- Connect Android real device to the machine(Desktop/Laptop)
- Turn on the developer options in android mobile (How to do it?)
- Enable USB debugging
- Run command
adb devices
in cmd prompt to check whether the device is recognised
- Open command prompt, go to
<sdk emulator path>
Command to stard AVD: `emulator -avd <avd_name>`
Command to stop/kill AVD: `adb -e emu kill`
- Copy the .apk file and paste it in the path -
<path to sdk platform-tools>
- Open the cmd terminal from the directory where APK file is placed and enter command
adb install <apk filename>
If the app is already installed on your device then we can make use of appPackage and appActivity to launch the app
- Open the app on the device, for which appPackage and appActivity is required.
- Open powershell and enter command
adb shell dumpsys window | grep -E 'mCurrentFocus|mFocusedApp'
- Start the Appium Server and connect with Real device/Emulator.
- Open Appium Inspector app and provide the appium server details and Desired Capabilities.
- Click on Start session which will start the appium inspector with layout shown below.
Type url `chrome://inspect/#devices` in the desktop chrome browser and start inspecting element
Add below lines in the Desired capabilities
options.setAvd("ArjitPhone");
or there is another method name - checkAndStartEmulator(deviceName, deviceId) in the CommonUtils Class
Start appium server using command appium --allow-insecure chromedriver_autodownload
Add below line in the AppiumServiceBuilder
builder.withArgument(GeneralServerFlag.ALLOW_INSECURE, "chromedriver_autodownload");
Use AppiumServiceBuilder
and AppiumDriverLocalService
to start the server programmatically Set environment
variable APPIUM_HOME = <path to npm folder>\node_modules\appium\build\lib
where main.js
file is present
👉 Supports Android - Real Devices and Emulators.
👉 Ability to start and stop the appium server on run-time.
👉 Page object model design.
👉 Supports capturing screenshots for failed steps
👉 Supports utilities to read test data from json file and provides data to each test based on the test name.
👉 Run test using command mvn test -Dgroups=<provide the group tag name to execute>
👉 Create or Select the required testng xml -> Right click and select Run