Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stefruseva88/appium-testing

Mobile Testing Automation with Appium and C#
https://github.com/stefruseva88/appium-testing

appium-android appium-csharp appium-tests

Last synced: 23 days ago
JSON representation

Mobile Testing Automation with Appium and C#

Awesome Lists containing this project

README

        

# Appium Mobile Automation Tests

[![C#](https://img.shields.io/badge/Made%20with-C%23-239120.svg)](https://learn.microsoft.com/en-us/dotnet/csharp/)
[![.NET](https://img.shields.io/badge/.NET-5C2D91.svg)](https://dotnet.microsoft.com/)
[![Android Studio](https://img.shields.io/badge/Built%20with-Android%20Studio-3DDC84.svg)](https://developer.android.com/studio)
[![Appium](https://img.shields.io/badge/tested%20with-Appium-41BDF5.svg)](https://appium.io/)

### This is a test project for Front-End Test Automation July 2024 Course @ SoftUni

## Overview
This repository demonstrates how to automate testing of Android mobile applications using **Appium** and **Page Object Model (POM)**.

## 1. "Summator" Page Object Model (POM)
**Summator** is a calculator Android application. The app allows users to perform simple arithmetic operations.

### 1.1 Automated Testing Scenario

The testing scenario involves the following steps:

1. **Open the Summator App.**
2. **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.

### 1.2 Configure Appium Inspector

To run tests, follow these steps to configure Appium Inspector:

1. **Start the Appium Server.**
If you're using the web version, start it with `--allow-cors` enabled.

2. **Start your Android Virtual Device (AVD).**

3. **Install the application** on your AVD by dragging and dropping the `.apk` file into the emulator.

4. **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 (use `appium driver list` to get the value)
- `platformVersion`: Get the Android version using `adb shell getprop ro.build.version.release`.
- `deviceName`: Use `adb devices` to find the connected device name.
- `app`: Path to the `.apk` file on your computer.
### 1.3 Identify Element IDs

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.

## 2. ColorNote App

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.

### 2.1 Automated Testing Scenarios

1. **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.

2. **Editing a Note:**
- Open the app and skip the tutorial.
- Add a new note, then edit its content.
- Verify the note has been updated.

3. **Deleting a Note:**
- Open the app and skip the tutorial.
- Add a new note, then delete it.
- Verify the note is successfully deleted.

### 2.2 Configuring Appium Inspector for ColorNote

1. **Start Appium Server and your AVD.**

2. **Install the app** on the AVD if not already installed.

3. **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.

### 2.3 Recording with Appium Inspector

To record steps for a scenario, follow these steps:

1. **Open the ColorNote App** and skip the tutorial.

2. **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.

3. **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.

### 2.4 Writing Tests for ColorNote

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]`.

#### Sample Test Scenarios:

- **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.

## License
This project is licensed under the [MIT License](LICENSE). See the [LICENSE](LICENSE) file for details.

## Contact
For any questions or suggestions, please open an issue in the repository.

---
### Happy Testing! πŸš€