- Automation Framework: Appium
- Build tool: Maven
- Bundled Tools: TestNG
- Language: Java
- Report: extent
- Project Structure: Page object Model(POM)
- Intellij idea (Or use any IDE you like that supports Java language programming)
- Java 11+
- npm or other package manager
- Appium Server (2.x) for installation check installation instruction
- Appium Inspector (https://github.com/appium/appium-inspector/releases)
- Android studio Emulator or Real Device check installation instruction
Download and install Android Studio based on your preferred OS. Then set your ANDROID_HOME by follow this steps:
This guide will walk you through setting the ANDROID_HOME variable on both Windows and macOS. The ANDROID_HOME variable is used by various tools and IDEs for locating the Android SDK installation directory.
-
Locate your Android SDK installation directory. By default, it's typically installed in
C:\Users\YourUsername\AppData\Local\Android\Sdk. -
Right-click on "This PC" or "My Computer" and select "Properties".
-
Click on "Advanced system settings" on the left side.
-
In the System Properties window, go to the "Advanced" tab and click on the "Environment Variables" button at the bottom.
-
In the Environment Variables window, under "System variables", click on "New".
-
For the Variable Name, enter
ANDROID_HOME. -
For the Variable Value, enter the path to your Android SDK installation directory (e.g.,
C:\Users\YourUsername\AppData\Local\Android\Sdk). -
Click "OK" to save the variable.
-
Click "OK" again to close the Environment Variables window.
-
You may need to restart your system for the changes to take effect, although restarting your command prompt or IDE may be sufficient.
Setting ANDROID_HOME on macOS
-
Open Terminal.
-
Run the command
nano ~/.bash_profileto open your bash profile (you can also use~/.zshrcif you are using Zsh). -
Add the following line at the end of the file:
export ANDROID_HOME=/Users/YourUsername/Library/Android/sdk
Replace /Users/YourUsername/Library/Android/sdk with the path to your Android SDK installation directory.
-
Save the file by pressing
Ctrl+X, thenY, and finally pressEnter. -
To make the changes take effect, either restart Terminal or run
source ~/.bash_profilein the terminal.
Remember to replace YourUsername with your actual username in the paths specified above.
- For Android: Go to Settings > About phone > Software info, then tap "Build number" 7 times to enable Developer Options. Once enabled, go to Settings > Developer options and enable USB debugging.
- Use a USB cable to connect your device to your computer.
- Open a terminal or command prompt.
- Run
adb devices. Your device should be listed. (for Android) - Run
xcrun xctrace list devices. Your device should be listed. (for iOS)
- Run
For more comfortable, you will also need it during the work process set next variables
platform-tools
cmdline-tools
cmdline-tools/bin
emulator
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/cmdline-tools:$PATH
export PATH=$ANDROID_HOME/cmdline-tools/bin:$PATH
export PATH=$ANDROID_HOME/emulator:$PATH
Use the process which is described above about how to set ANDROID_HOME
warning!
if you use old android studio version, you needs:
platform-tools
tools
tools/bin
emulator
instead of
platform-tools
cmdline-tools
cmdline-tools/bin
emulator
Open Android Studio -> More Actions -> Virtual Device Manager -> Create device -> Choose any type of device you want (in this tutorial I use Pixel 4 with Google Play) -> Choose your Android version which we have installed in previous steps (API 33 with Google Play).
Run your previously created Android emulator.
Open your terminal or cmd then enter command and wait for installation to finish
npm install -g appium@next or will be better npm install -g appium@2.5
Install Appium 2 driver for Android using terminal
appium driver install uiautomator2
Check if uiautomator2 driver is installed
appium driver list
Install the plugin using Appium's plugin CLI, either as a named plugin or via NPM:
appium plugin install --source=npm appium-device-farm
appium plugin install --source=npm appium-dashboard
The plugin will not be active unless turned on when invoking the Appium server. See "Argument options" below
appium server -ka 800 --use-plugins=device-farm,appium-dashboard -pa /wd/hub --plugin-device-farm-platform=android
You can define as well device type "android" , "ios" or "both"
you can block/unblock devices from Dashboard manually. These devices will not be picked up for automation. Once automation picks the device user cannot manually unblock, it's responsible for the automation script. dashboard will be: localhost:4723/device-farm for more information check Appium Device Farm Doc.
Set Driver Capabilities
In order for Appium to be able to connect to your device and app, you need to fill in some information about your testing environment such as device and application information. Find your Android emulator UDID by using terminal and enter this command:
adb devices // but if you use device-farm you don't need device UDID
Copy this JSON capabilities into your Appium Inspector (for ANDROID)
{
"platformName": "Android",
"appium:udid": "yourudid", // if you need this
"appium:appPackage": "com.google.android.youtube",
"appium:appActivity": "com.google.android.youtube.app.honeycomb.Shell$HomeActivity",
"appium:deviceName": "yourdevicename",
"appium:automationName": "UiAutomator2",
"appium:autoGrantPermissions": true
}
Copy this JSON capabilities into your Appium Inspector (for IOS)
{
"appium:platformName": "ios",
"appium:automationName": "XCUITest",
"appium:udid": "ios device udid",
"appium:forceEspressoRebuild": true,
"appium:printPageSourceOnFindFailure": true,
"appium:printPageSourceOnFindFailure": true
"appium:bundleId": "ios app bundle id"
}
Replace “yourudid” in “appium:udid” with your UDID which you found in this previous step.
Replace “yourdevicename” in “appium:deviceName” with you Android emulator name. You can find information about your device name in Android Studio -> Device Manager.
Pixel 4 API 33 is the name of my emulator device.
Actually there are 2 ways to set which application you will automate:
By using capability of “appium:app”, with this your apk is not pre-installed on your device and will be installed each time your test run. If you are using this type of capability then you don’t need to use “appium:appPackage” and “appium:appActivity” as we used in the previous steps.
- Prepare Emulator or real device
- Run Appium server
- check config.properties before execute
- Run the testng/*.xml file(s) or use mvn command
mvn clean test -Dplatform=android or ios -Denv=dev or qa. - After Complete the test execution Report will generate to "report" Folder if it will be enabled from config
-
src/: Contains the source code of the project.java/: Contains the Java source files.uz.tbcBank: main packageHelpers: classes of HelpersExtendReport: The ExtentReport class is a helper class that provides methods for creating and managing ExtentReports objects for generating test reportsConfig: The Config class loads a configuration file and provides a way to read its properties, with a singleton pattern implementationListener: It implements the ITestListener interface and overrides all of its methodsUtils: The Utils class contains various utility methods
Page/{teamName}/{moduleName}: Java class that contains locators and methods (Page Object)test/: Contains the test source code files.test/{teamName}/{moduleName}: Java class that contains test cases as methods and BaseTest.javaBaseTest: The BaseTest class in Java sets up and initializes the driver with desired capabilities for Android and iOS platforms
resources/app/{env}/app.apk: .apk file for testingresources/{env}.xml: xml files which contains constants/strings depending on the environment
-
pom.xml: Maven configuration file for your project. -
target/: Contains compiled classes and packaged artifacts (created after building the project). -
README.md: This README file providing an overview of the project. -
config.properties: common config data. -
report: contains reporting files index.html (you can open it in any browser) + screenshots -
app.log: contains logs -
testng/*.xml: testng files






