This repository contains an example implementation of mobile automation using Appium, focusing on interacting with Android applications. The project covers setting up Appium, writing automation scripts in Python, handling UI elements, and integrating with a continuous integration (CI) pipeline.
Appium is an open-source automation framework for automating native, mobile web, and hybrid applications on iOS and Android platforms. Appium operates on a client-server architecture. The Appium server is responsible for receiving commands from the client (such as a test script written in Python or Java), executing those commands on the mobile device or emulator, and sending back the results.
Appium, Server Based Automation For Mobile Apps
The automation script demonstrates:
- Launching the Android application using Appium
- Identifying & interacting with UI elements such as EditText (username and password fields) and TextView (login button)
- Using dynamic data (date formatting) as input (password attempts)
- Integrating with a continuous integration (CI) pipeline for automated testing
Before running the automation scripts, ensure you have the following installed and configured:
- Python (3.x recommended)
- Appium Server
- Android SDK tools
- Appium Python client (
appium-python-client
) - Java Development Kit (JDK)
- UIAutomator2 Driver
- Developer options enabled on your Android device with USB debugging
- Download Python: Go to the official Python website and download the latest version of Python.
- Install Python: Run the installer and ensure that you select the option to add Python to your system PATH during installation.
- Download JDK: Go to the Oracle JDK download page and download the latest JDK.
- Install JDK: Run the installer and follow the prompts.
- Set JAVA_HOME Environment Variable:
- Open the Start Menu, search for "Environment Variables," and select "Edit the system environment variables."
- In the System Properties window, click "Environment Variables."
- Under "System variables," click "New" and set the
JAVA_HOME
variable to the path of your JDK installation (e.g.,C:\Program Files\Java\jdk-13
). - Find the
Path
variable in the list, select it, and click "Edit." Add a new entry with the path to the JDK'sbin
directory (e.g.,C:\Program Files\Java\jdk-13\bin
).
-
Download Android SDK Command-line Tools: Go to the Android developer site and download the SDK command-line tools.
-
Extract and Install SDK Tools:
-
Extract the downloaded tools to a directory of your choice.
-
Open a command prompt and navigate to the extracted directory.
-
Run the following commands to install the SDK and platform tools:
sdkmanager --install "platform-tools" "platforms;android-30" "build-tools;30.0.3"
-
-
Add SDK Tools to PATH:
- Open the Start Menu, search for "Environment Variables," and select "Edit the system environment variables."
- In the System Properties window, click "Environment Variables."
- Find the
Path
variable in the list, select it, and click "Edit." Add a new entry with the path to theplatform-tools
directory within the SDK installation (e.g.,C:\Users\YourUsername\Android\Sdk\platform-tools
).
-
Install Node.js and npm: Appium is built on Node.js, so you need to install Node.js first.
- Download and install Node.js from the official website.
-
Install Appium: Once Node.js and npm are installed, you can install Appium globally using npm.
-
Open a command prompt and run the following command:
npm install -g appium
-
-
Install Appium Doctor: Appium Doctor helps verify that your system is properly configured.
-
Run the following command to install Appium Doctor:
npm install -g appium-doctor
-
-
Verify Appium Installation:
-
Run the following command to check that Appium is installed correctly:
appium-doctor
-
- Install UIAutomator2 Driver:
-
Open a command prompt and run the following command:
npm install -g appium-uiautomator2-driver
-
-
Enable Developer Options:
- Open the Settings app on your Android device.
- Scroll down and select "About phone."
- Find the "Build number" entry and tap it seven times. You should see a message indicating that Developer options are now enabled.
-
Enable USB Debugging:
- Go back to the main Settings menu and select "System."
- Select "Developer options."
- Find and enable the "USB debugging" option.
-
Connect Your Android Device:
- Connect your device to your computer using a USB cable.
- You may need to allow USB debugging permissions on your device when prompted.
-
Install SDK Tools:
-
Open a command prompt and navigate to your SDK tools directory.
-
Run the following command to install additional tools:
sdkmanager --install "tools"
-
-
Launch UIAutomatorViewer:
-
Navigate to the
tools/bin
directory within your Android SDK installation. -
Run the following command to launch UIAutomatorViewer:
uiautomatorviewer.bat
-
UIAutomatorViewer is a GUI tool to inspect the UI components of your Android application. It helps you understand the structure of the UI elements, which is essential for writing reliable Appium tests.
- Install Appium Python Client:
-
Open a command prompt and run the following command:
pip install Appium-Python-Client
-
- Clone this repository:
git clone https://github.com/git-aamar/Android-App-Automated-Brute-Force-Login-using-Appium.git
cd appium-mobile-automation
- Install dependencies:
pip install -r requirements.txt
- Setting Up Appium:
$ appium
- Update
desired_caps
in test_script.py with your device details:
desired_caps = {
'platformName': 'Android',
'platformVersion': '13', # Replace with your Android version
'deviceName': 'Samsung Galaxy A71 5G', # Replace with your device name
'appPackage': 'app.progres.webetu', # Replace with your app package name
'appActivity': '.MainActivity', # Replace with your app's main activity
'noReset': True
}
- Run the script after tailoring it to your application:
$ python appium_python_script.py
You can integrate this project with your CI/CD pipeline (e.g., Jenkins, GitLab CI) for automated testing on every commit or merge to the main branch. Configure your CI tool to execute python test_script.py as part of your pipeline steps.
Contributions are welcome! Feel free to submit issues for bugs, feature requests, or pull requests with improvements.
This project is licensed under the MIT License - see the LICENSE file for details.
If you find RepoUp useful, consider supporting me by:
- Starring the repository on GitHub
- Sharing the tool with others
- Providing feedback and suggestions
- Follow me for more :)
For any issues or feature requests, please open an issue on GitHub. Happy coding!