Skip to content

KrishnaPukale11/Appium_Python_Framework

Repository files navigation

Appium Integration for Pytest Framework

Step 1: Install Android Studio and Set Up Environment Variables

  1. Download and Install

Visit the Android Studio website and download the installer for your OS.

Run the installer and follow the setup wizard to install Android Studio and required SDK components.

  1. Install Android Studio

Run the downloaded installer.

Follow the installation wizard steps.

During installation, select the necessary SDK components.

  1. Verify Installation

Open Android Studio after installation.

Complete the setup wizard to ensure all SDK components are installed.

  1. Set Up Environment Variables (Windows)

Open System Properties → Environment Variables.

Add a new System Variable:

Name: ANDROID_HOME Paste following path into the value column C:\Users{userName}\AppData\Local\Android\Sdk

Then Add below into path variable:

%Android_Home%\platform-tools

%Android_Home%\tools

%Android_Home%\build-tools

Restart your terminal or IDE.

Step 2: Install Gradle and Set Up Environment Variables

  1. Download Gradle

Visit the Gradle website and download the Complete distribution.

  1. Extract Gradle

Extract the downloaded ZIP file to a preferred location (e.g., C:\Gradle).

  1. Set Up Environment Variables (Windows)

Open System Properties → Environment Variables.

Add a new System Variable:

Name: GRADLE_HOME

Value: Path to the Gradle folder (e.g., C:\Gradle\gradle-x.x).

Update the Path variable under System Variables:

Add: %GRADLE_HOME%\bin

Save changes and restart your terminal or IDE.

Step 3: Install Appium Inspector

  1. Download Appium Inspector

Go to the Appium Inspector GitHub page.

Download the installer for your operating system.

  1. Install Appium Inspector

Run the downloaded installer and follow the instructions to complete the installation.

  1. Verify Installation

Launch Appium Inspector to ensure it's installed and working correctly.

Step 4: Install Java 11

  1. Download Java 11

Visit the Oracle Java Downloads page or OpenJDK page.

Download the Java 11 installer for your operating system.

  1. Install Java 11

Run the installer and follow the instructions to complete the installation.

Note the installation path (e.g., C:\Program Files\Java\jdk-11.x.x).

  1. Set Up Environment Variables (Windows)

Open System Properties → Environment Variables.

Add a new System Variable:

Name: JAVA_HOME

Value: Path to the Java installation folder (e.g., C:\Program Files\Java\jdk-11.x.x).

Update the Path variable under System Variables:

Add: %JAVA_HOME%\bin

Save changes and restart your terminal or IDE.

  1. Verify Installation

Open a terminal and run:

java -version

Ensure it shows Java 11.

Step 5: Install and Set Up Appium Server

  1. Install Appium Server

Install Appium globally using Node.js:

npm install -g appium

  1. Verify Installation

Check if Appium is installed correctly:

appium --version

  1. Start Appium Server

Run the following command to start the Appium server:

appium -p 4723

The server will start and listen on the default port 4723.

Step 6: Install UIAutomator2 Driver

  1. Install the Driver

Use the following Appium command to install the UIAutomator2 driver:

appium driver install uiautomator2

  1. Verify Installation

Check if the UIAutomator2 driver is installed by listing all installed drivers:

appium driver list

Ensure uiautomator2 appears in the list.

  1. Configure the Driver

UIAutomator2 is typically the default driver for Android devices. No additional configuration is required unless you need specific capabilities.

  1. Install Chromium Driver

Run:

npm install appium-chromedriver

Step 7: Install and Set Up Python

  1. Download Python

Visit the Python website and download the latest version of Python 3.x.

  1. Install Python

Run the installer and check the option "Add Python to PATH" before starting the installation.

Follow the installation steps to complete the setup.

  1. Verify Installation

Open a terminal and run:

python --version

Ensure it displays the installed Python version.

  1. Install pip (if not installed)

Run the following command to ensure pip, the Python package manager, is installed:

python -m ensurepip --upgrade

  1. Set Up Virtual Environment (Optional)

Create a virtual environment for your project:

python -m venv venv

Activate the virtual environment:

Windows: venv\Scripts\activate

macOS/Linux: source venv/bin/activate

Step 8: Create a Virtual Device in Android Studio

  1. Open AVD Manager

Launch Android Studio.

Navigate to Tools → Device Manager (or AVD Manager).

  1. Create a New Virtual Device

Click on Create Device.

Select a device model from the list (e.g., Pixel 4) and click Next.

  1. Choose a System Image

Select the desired Android version (e.g., Android 14.0).

Download the system image if not already available and click Next.

  1. Configure the Virtual Device

Set the device orientation, scale, and other preferences.

Click Finish to create the virtual device.

  1. Start the Virtual Device

In the Device Manager, click the Play button next to the virtual device to launch it.

Step 9: Install Telegram App on the Android Virtual Device

  1. Launch the Virtual Device

Open Android Studio → Device Manager → Start your virtual device.

  1. Open Google Play Store

Navigate to the Google Play Store app on the virtual device.

Sign in with your Google account if prompted.

  1. Search for Telegram

Use the search bar to find the Telegram app.

  1. Install Telegram

Select the Telegram app from the search results.

Click Install and wait for the installation to complete.

  1. Verify Installation

Open the Telegram app to ensure it launches successfully.

Step 10: Install PyCharm and Set Up Appium Python Client 3.0

  1. Download PyCharm

Visit the PyCharm website and download the appropriate version for your operating system.

  1. Install PyCharm

Run the installer and follow the setup instructions to complete the installation.

  1. Install Appium Python Client 3.0

Open a terminal or PyCharm’s terminal and run the following command to install the Appium Python client:

pip install Appium-Python-Client==3.0

  1. Verify Installation

In PyCharm, create a new Python file and import the Appium client to check if it's installed correctly:

from appium import webdriver

  1. Configure PyCharm for Appium Python Development

Open PyCharm and configure the Python interpreter for your project (using the virtual environment, if created).

Ensure all dependencies are set up for your Appium Python framework.

Step 11: Clone the Git Repository into Local

  1. Install Git (if not already installed)

Visit the Git website and download the latest version of Git for your operating system.

Follow the installation instructions to complete the setup.

  1. Open Git Bash

Launch Git Bash from the Start menu or applications folder.

  1. Clone the Repository

In Git Bash, navigate to the folder where you want to clone the repository using the cd command.

Run the following command to clone the repository:

git clone

Replace with the actual URL of your Git repository.

  1. Verify the Clone

Navigate into the cloned directory:

cd

List the files to ensure the repository has been cloned:

ls

Step 12: Create a Virtual Environment for pytest

  1. Navigate to Your Project Directory

Open a terminal and navigate to your project folder (where the Appium framework is cloned):

cd

  1. Create a Virtual Environment

Run the following command to create a virtual environment:

python -m venv venv

  1. Activate the Virtual Environment

Windows:

venv\Scripts\activate

macOS/Linux:

source venv/bin/activate

  1. Install pytest

Once the virtual environment is activated, install pytest:

pip install pytest

  1. Verify Installation

Check if pytest is installed correctly:

pytest --version

Step 13: Start AVD and Appium Server

  1. Start the AVD

Open Android Studio → Device Manager and click the Play button next to your virtual device to launch it.

  1. Ensure the Device is Detected

Open a terminal and run the following command to check if the device is detected:

adb devices

Ensure your device is listed under "List of devices attached".

  1. Start the Appium Server

In the terminal, start the Appium server by running:

appium -p 4723

This will start the Appium server on port 4723.

Step 14: Run the Test in Telegram_demo.py

  1. Open the Test File

Open your test file (e.g., Telegram_demo.py) in your preferred editor (e.g., PyCharm).

  1. Ensure AVD is Running

Verify that your Android Virtual Device (AVD) is turned on and running by checking if the device is visible in Device Manager in Android Studio.

  1. Run the Test Using pytest in Terminal

In PyCharm's terminal, run the test using pytest:

pytest -k test_send_message

This will execute the test_send_message() test case from the Telegram_demo.py file.

  1. Run the Test Using Test Explorer in PyCharm

In PyCharm, open the Run menu and select Run 'pytest'.

Alternatively, you can click on the Test Explorer window on the right side of PyCharm.

Find the test case test_send_message in the list of available tests and click the Run button (green triangle) next to it.

  1. Verify Test Execution

Ensure that the test passes and

Value: Path to the Android SDK (e.g., C:\Users<YourUsername>\AppData\Local\Android\Sdk).

Update the Path variable under System Variables: that the message is sent successfully on the Telegram app running on the AVD.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages