What is the correct way to use the POP with Xamarin.UITest? RRS feed

  • Question

  • User398676 posted

    Hi, I'm developing a Xamarin.Forms application and I want to use Xamarin.UITest with the POP (Page Object Pattern) to test the UI. I read the documentation and had the chance to see a keynote about this tool and this pattern, but I still don't understand which is the correct way to conditionally test the UI. For example, in my test project, I have a Pages folder and a Tests folder. In the first one, I put the pages' representations, while in the second one I put the tests I made about these representations. I want to test the entry input when the user tries to log in. So far, I wrote this method inside the TestProject/Pages/LoginPage.cs file:

    public LoginPage EnterCredentialsAndLogin(string email, string password) {
        if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) {
        else {

    and I test it using this code in the TestProject/Tests/LoginPageTests.cs file:

    public void TestLoginWithDifferentCredentials() {
        new LoginPage().EnterCredentialsAndLogin(null, null);
        new LoginPage().EnterCredentialsAndLogin("", null);
        new LoginPage().EnterCredentialsAndLogin("email", null);
        new LoginPage().EnterCredentialsAndLogin("email", "");
        new LoginPage().EnterCredentialsAndLogin(null, "");
        new LoginPage().EnterCredentialsAndLogin(null, "password");
        new LoginPage().EnterCredentialsAndLogin("", "password");

    Is this an appropriate way to use the POP? Should I use other approaches?

    Tuesday, February 16, 2021 4:58 PM

All replies

  • User387683 posted

    You could check the link below with the samples. https://devblogs.microsoft.com/xamarin/best-practices-tips-xamarin-uitest/

    Wednesday, February 17, 2021 8:44 AM
  • User398676 posted

    Hi, WendyZang. Thanks for your response. Unfortunately, in this snippet of code:

    new LogInPage()
        .EnterCredentials("name", "password")

    I don't understand what should be the logic to, for example, check non-empty credentials.

    Wednesday, February 17, 2021 9:27 AM
  • User387683 posted

    The snippet is used for example. The blog provide the sample for that. You could check the link for Channel9. https://channel9.msdn.com/Shows/XamarinShow/Best-Practices-for-User-Interface-Automation

    What you have tried? What is the error for now?

    Thursday, February 18, 2021 8:29 AM