-
Notifications
You must be signed in to change notification settings - Fork 23
POP Implementation
This guide will walk you through setting up your project for cross-platform tests using the page object pattern. With minor edits you can also use this pattern for single platform tests.
-
Create a new test project or open up your existing one
-
Make sure the Xamarin.UITest NuGet package is fully up to date and the NUnit NuGet package is on version 2.6.4
-
Install the Xamarin.UITest.POP NuGet package, which will add all the necessary files to your project
Alternatively, you can manually add the following files to your project (making sure to change the namespaces to match your own):
-
Remove AppInitializer.cs (if it exists)
-
Edit
AppManager.StartApp
so that the calls toConfigureApp
point to the appropriate app binariesIf your test project is in the same solution as your application project(s), you can skip this step since the IDE will provide the binary location information to UITest directly
For Android:
app = ConfigureApp .Android .ApkFile("path/to/file.apk") .StartApp();
For iOS simulators:
app = ConfigureApp .iOS .AppBundle("path/to/file.app") .StartApp();
For iOS devices:
app = ConfigureApp .iOS .InstalledApp("com.company.bundleid") .StartApp();
-
Create a folder for your test classes and a folder for your page classes to help keep things organized
-
Create a page object classes that inherits from
BasePage
for each page in your app -
Make sure that your test fixture classes inherit from
BaseTestFixture
. Your test fixtures should look like this:public class Tests : BaseTestFixture { public Tests(Platform platform) : base(platform) { } [Test] public void AppLaunches() { app.Screenshot("First screen."); } }
-
Now, from your tests, call methods on the page objects to automate your app. For example:
[Test] public void LogInTest() { new LogInPage() .EnterCredentials("username", "password") .ConfirmLogIn(); new HomePage(); }