This repository demonstrates how to automate testing of Android mobile applications using Appium and Page Object Model (POM).
Summator is a calculator Android application. The app allows users to perform simple arithmetic operations.
The testing scenario involves the following steps:
- Open the Summator App.
- Perform tests with both valid and invalid inputs:
- For valid inputs, verify the calculation results are correct.
- For invalid inputs, ensure that an "error" message is displayed in the result field.
To run tests, follow these steps to configure Appium Inspector:
-
Start the Appium Server.
If you're using the web version, start it with--allow-cors
enabled. -
Start your Android Virtual Device (AVD).
-
Install the application on your AVD by dragging and dropping the
.apk
file into the emulator. -
Set up Appium Inspector:
- Provide the host and port of your Appium server (e.g.,
http://127.0.0.1:4723
). - Add the desired capabilities:
automationName
:UiAutomator2
platformName
: Android (useappium driver list
to get the value)platformVersion
: Get the Android version usingadb shell getprop ro.build.version.release
.deviceName
: Useadb devices
to find the connected device name.app
: Path to the.apk
file on your computer.
- Provide the host and port of your Appium server (e.g.,
Using Appium Inspector, retrieve the IDs of the elements you need for testing, such as text fields, buttons, etc. For example:
- Click on a field, and the ID will be displayed in the "Selected Element" panel.
The ColorNote app is a simple notepad application that allows users to create, edit, and delete notes. We will create automated tests for various scenarios in this app.
-
Creating a New Note:
- Open the app and skip the tutorial.
- Add a new note with a title and content.
- Verify the note is successfully created.
-
Editing a Note:
- Open the app and skip the tutorial.
- Add a new note, then edit its content.
- Verify the note has been updated.
-
Deleting a Note:
- Open the app and skip the tutorial.
- Add a new note, then delete it.
- Verify the note is successfully deleted.
-
Start Appium Server and your AVD.
-
Install the app on the AVD if not already installed.
-
Configure Appium Inspector:
- Use the same host and port (
http://127.0.0.1:4723
). - Add the desired capabilities, including:
"appium:autoGrantPermissions": "true"
to automatically handle permission dialogs.
- Use the same host and port (
To record steps for a scenario, follow these steps:
-
Open the ColorNote App and skip the tutorial.
-
Add a new note:
- Click the "+" or "Add Note" button.
- Select "Text" to create a text note.
- Type the content of the note, and confirm with the "Tick" symbol.
-
Pause the recording and view the elements and actions in the "Recorder" tab.
You can view boilerplate code generated by the Inspector as a reference, but it’s essential to refactor the code to follow best practices.
Create tests in Visual Studio using NUnit and Appium:
- Install the Appium.WebDriver package from the NuGet Package Manager.
- Define your test class:
Use[TestFixture]
to mark the class as a test suite and configure the setup and teardown methods using[OneTimeSetUp]
and[OneTimeTearDown]
.
-
Test to Create a Note:
- Add a new note and verify it is displayed on the main screen.
-
Test to Edit a Note:
- Modify an existing note and verify the changes.
-
Test to Delete a Note:
- Delete a note and verify it is removed from the app.
Contributions are welcome! If you have any improvements or bug fixes, feel free to open 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 in the repository.