Welcome to my Appium testing repository! In this repository, I document my journey of learning Appium testing, starting with the first script. The provided code demonstrates how to interact with the YouTube mobile application using Appium.
Before getting started with Appium testing, make sure you have the following prerequisites in place:
-
Java Development Kit (JDK) installed on your machine.
-
Android SDK with necessary build tools and platform tools.
-
Node.js installed on your machine. You can download Node.js from the official website: https://nodejs.org
-
Appium installed globally on your machine. Install Appium by running the following command in your terminal:
npm install -g appium
-
An Android device or emulator connected to your machine.
To set up your environment for Appium testing, follow these steps:
-
Clone this repository to your local machine using the following command:
git clone https://github.com/iDereje/appiumtest.git
-
Open the project in your preferred Java IDE.
-
Configure the necessary dependencies in your project's build path:
- Add the required Appium Java client library.
- Add the necessary Selenium libraries.
-
Connect your Android device or start an emulator.
-
Open a new terminal window and start the Appium server by running the following command:
appium
This will start the Appium server and listen for connections on the default port (4723).
With these updates, you have the necessary prerequisites in place, including Node.js and running the Appium server through npm. Now you can proceed with running the test script.
The code in the YoutubeMobile
class showcases my first Appium test script for automating actions within the YouTube mobile app. Let me explain the different sections of the script:
-
Setting Desired Capabilities:
- I set the platform name to Android using
MobileCapabilityType.PLATFORM_NAME
. - The
appPackage
capability specifies the package name of the YouTube app. - The
appActivity
capability specifies the main activity of the YouTube app.
- I set the platform name to Android using
-
Creating an Android Driver:
- I create an instance of the
AndroidDriver
class to establish a connection to the Appium server using the specified capabilities and server URL.
- I create an instance of the
-
Searching for a Video:
- To search for a video, I locate the search box element using its ID (
com.google.android.youtube:id/search_edit_text
). - I send the search query "Appium tutorial" to the search box.
- The search button element is located by its ID (
com.google.android.youtube:id/search_button
). - I click the search button to perform the search.
- To search for a video, I locate the search box element using its ID (
-
Selecting a Search Result:
- I locate the first search result using an XPath expression (
//android.widget.TextView[@text='Appium Java Tutorial - Complete Beginner's Guide']
). - I click on the first search result.
- I locate the first search result using an XPath expression (
-
Playing the Video:
- I locate the play button element by its ID (
com.google.android.youtube:id/player_control_play_pause_replay_button
). - I click the play button to start playing the video.
- I locate the play button element by its ID (
To run the provided test script:
-
Make sure your Android device or emulator is connected and accessible.
-
Run the
main
method in theYoutubeMobile
class. -
Observe the execution of the script, which will perform the following actions:
- Launch the YouTube app.
- Search for the "Appium tutorial" video.
- Select the first search result.
- Play the video.
-
Check the execution output and verify that the actions were performed successfully.
This script is just the beginning of my Appium testing journey. From here, I plan to explore and expand my test scenarios by interacting with different elements and performing various actions within the YouTube app. I will also delve into advanced Appium features and practices to enhance my testing capabilities.
I'm excited to continue exploring the world of Appium testing, experimenting with different scenarios, and integrating it into my test automation workflows. With Appium, I can automate tests across multiple platforms and devices, ensuring the quality and reliability of my mobile applications.
Contributing
I welcome contributions to this repository! If you have any improvements, additional examples, or suggestions, please feel free to open a pull request.
Feel free to modify and use the code for your own purposes.
For any questions or inquiries, please feel free to contact me at
Thank you for joining me on my Appium testing journey!
Repository URL: https://github.com/iDereje/appiumtest