This project is designed to automate mobile application testing using Appium, TestNG, and Java. It focuses on testing the login functionality of a sample mobile application. The project includes a robust setup for starting and stopping the Appium server, initializing the Android driver, and running TestNG test cases.
- π Overview
- π§ Prerequisites
- βοΈ Setup
- π Project Structure
βΆοΈ Running the Tests- π Project Details
- π Logging
- π₯ Contributors
- π€ Contributing
- π License
- π Contact
- Java Development Kit (JDK) 11 or higher
- Apache Maven
- Node.js and npm
- Appium Server
- Appium Inspector
- Appium Doctor
- Android SDK
- Android Emulator or a Physical Android Device
- Download and install JDK from Oracle.
- Set
JAVA_HOME
environment variable. - Environment Variable Setup:
- Open the command prompt and run
where java
to find the Java installation path. - Add the Java installation path to the environment variables:
Path
:C:\Program Files\Java\jdk-11\bin
JAVA_HOME
:C:\Program Files\Java\jdk-11
- Add
%JAVA_HOME%\bin
to the systemPath
.
- Open the command prompt and run
- Download and install Maven from Maven.
- Set
MAVEN_HOME
environment variable.
- Install Node.js from Node.js.
- Run the following commands in the command prompt:
npm install -g appium npm install -g appium@next appium -v
- Run the following commands in the command prompt:
npm install @appium/doctor --location=global appium-doctor --android
- Download the Appium Desktop application from Appium and install it.
- Alternatively, you can start the Appium server from the command line:
appium
- Run the following commands in the command prompt:
appium driver install uiautomator2 appium driver list
If you are using MacOS and need to test iOS devices, you should install the XCUITest driver:
appium driver install xcuitest
-
Download and install the Android SDK from Android Studio.
-
Environment Variable Setup:
- Add the following to the system environment variables:
ANDROID_HOME
:C:\Users\YourUsername\AppData\Local\Android\Sdk
Path
:%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\cmdline-tools
- Add the following to the system environment variables:
-
SDK Setup in Android Studio:
- Open Android Studio and go to
More actions
>SDK Manager
. - Under
SDK Platforms
, ensureAndroid API 34
is selected. - Under
SDK Tools
, ensure the following are installed:Android SDK Build-Tools 34
Android SDK Command Line Tools
Android SDK Tools (Obsolete)
(Uncheck "Hide Obsolete Packages" to see this)Android Emulator
Android Emulator hypervisor driver (for AMD processors)
Android SDK Platform-Tools
Intel x86 Emulator Accelerator (HAXM installer)
(Ensure virtualization is enabled in BIOS)
- Open Android Studio and go to
- For AMD processors, ensure
Android Emulator Hypervisor Driver for AMD Processors (installer)
is selected and applied.
- Open Windows Features and ensure the following are NOT selected:
Hyper-V
Virtual Machine Platform
Windows Hypervisor Platform
Appium Inspector is a tool for inspecting mobile applications. To install it, download the latest version from the Appium Inspector releases page and follow the installation instructions for your operating system.
Appium_TestNG_MobileAutomationTesting
βββ .idea
βββ src
β βββ apk
β βββ main
β βββ test
β βββ java
β βββ com
β βββ webdriverio
β βββ base
β βββ pages
β βββ tests
β βββ utils
β βββ resources
β βββ logs
β βββ log4j2.xml
βββ target
βββ .gitignore
βββ Appium_TestNG_MobileAutomationTesting.iml
βββ LICENSE
βββ pom.xml
βββ README.md
βββ testng.xml
- com.webdriverio.base: Contains base classes for the project.
- com.webdriverio.pages: Contains page object classes for the mobile application.
- com.webdriverio.tests: Contains TestNG test classes.
- com.webdriverio.utils: Contains utility classes for the project.
- resources.logs: Contains log configuration files.
Important: Ensure that your Android device or emulator is running and properly configured before executing the tests.
-
Clone the Repository:
git clone https://github.com/ChatGTHB/Appium_TestNG_MobileAutomationTesting.git cd Appium_TestNG_MobileAutomationTesting
-
Start Android Emulator or Connect a Physical Device:
- Start your Android emulator from Android Studio or connect a physical device via USB and ensure it is in developer mode.
-
Run the Tests:
- Use Maven to run the tests:
mvn clean test
- Use Maven to run the tests:
-
Start Android Emulator or Connect a Physical Device:
- Start your Android emulator from Android Studio or connect a physical device via USB and ensure it is in developer mode.
-
Run the Tests from LoginTest Class:
- Open the
LoginTest
class in your IDE. - Right-click on the class or the test method and select
Run 'LoginTest'
orRun 'testLogin'
.
- Open the
- AppiumServer Class: Manages the Appium server lifecycle.
- DriverManager Class: Handles the initialization of the Android driver.
- LoginPage Class: Contains methods to interact with the login page.
- LoginTest Class: Contains TestNG test cases for verifying the login functionality.
The project uses Log4j2 for logging. Configuration is set in the log4j2.xml
file located in the src/test/resources/logs
directory. Logs provide detailed information about the test execution and any issues encountered.
Contributions are welcome! Please fork the repository and create a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
For any questions or suggestions, please open an issue or contact the repository owner.