iOS
This quick start will get you up and running with writing UI tests for an iOS application using Appium and Legerity.
Note
It is recommended that a macOS device is used for this quick start.
Prerequisites
This quick start requires the following:
- An understanding of Selenium and working with the WebDriver APIs in .NET
- An understanding of Appium and working with the capabilities for iOS
- A functioning installation of the .NET runtime and SDK
- A functioning installation of Xcode on macOS with simulators installed
Install Legerity templates
Legerity includes project templates to simplify the creation of new UI test projects. To install the templates, run the following command:
dotnet new -i Legerity.Templates
When creating a project, the template will automatically add to an existing solution file if it can locate one, otherwise you will have to add it manually.
Create a new iOS UI test project with NUnit
To create a new iOS UI test project with NUnit in your existing repository, created a new project folder and from within it, run the following command:
dotnet new legerity-ios
This will create a new iOS UI test project with the following structure:
MyProject
├── Elements
├── Pages
│ └── SamplePage.cs
├── Tests
│ └── SampleTests.cs
├── BaseTestClass.cs
├── GlobalUsing.cs
├── MyProject.csproj
The project will include dependencies for NUnit, Appium, and Legerity for iOS.
The BaseTestClass
class is a simple abstraction used for all of your test classes, based on the Legerity LegerityTestClass
. The base test class is a great way to centralize common logic for your tests, to abstract the boilerplate code away from your tests, such as managing the application drivers.
Note
The BaseTestClass
in this template shows how to configure the application to launch on an iPhone SE (3rd generation) Simulator. This should be updated to launch your own application via the IOSApplication
constant and the device configuration in the PlatformOptions
.
The SamplePage
and SampleTests
classes are used to show the basic structure of a page object and test class. In this template, they highlight finding a button by name and verifying it is shown.
Note
The SamplePage
and SampleTests
classes are intended to be used as a guide for structuring tests. These should be removed and replaced with your own tests and page objects.
Dive into more
Now that you have your test project up, you can dive deeper into: