Code Monkey home page Code Monkey logo

maui.uitesting's Introduction

.NET MAUI UI Testing

.NET MAUI is the evolution of Xamarin.Forms, now it's time for the evolution of UI Testing .NET apps.

This project aims to bring an existing UI Testing spike and idea closer to a usable tool for creating UI Automation Tests for .NET MAUI apps. It is a simpler architecture than its predecessor Xamarin.UITest, and has a much cleaner integration than Appium, built with .NET MAUI apps first in mind.

.NET MAUI UI Testing - HackWeek

NuGet.org Packages

Nuget: Interactive For .NET Interactive Notebooks

Nuget: Unit Test Driver xUnit/NUnit Unit Test projects

Nuget: App Agent Include in your app project.

Features

  • Support for: Android, iOS, WindowsAppSDK, MacCatalyst * (Incomplete Driver)
  • gRPC communication channel between Driver and App Agent
  • .NET MAUI first view tree inspection and querying
  • Android - ADB integrations for advanced test manipulation
  • iOS - idb_companion for advanced test manipulation
  • Windows - WinAppDriver for additional manipulation
  • Fluent Driver API for view querying/actions
  • .NET Interactive Notebook for iterating on test writing / view tree & app exploration

Future ideas

  • Create native Android and iOS App Agent libraries that implement the gRPC spec so non-MAUI apps can be tested

maui.uitesting's People

Contributors

colombod avatar redth avatar stephen-hawley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maui.uitesting's Issues

Does it support Shell and Shell Navigation?

I try this project to the default mauiapp template by Visual Studio 2022 (v17.4.1).

I set the button of "MainPage.xaml" and its' AutomationId is "CounterBtn".

UITest code is:

await driver.AutomationId("CounterBtn").Tap();

When I set

MainPage = new MainPage(); 

at App.xaml.cs, it can work will.

But when I set

MainPage = new AppShell();

at App.xaml.cs and AppShell.xaml is:

<Shell
    x:Class="MauiApp2.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:MauiApp2"
    Shell.FlyoutBehavior="Disabled">
    <ShellContent
        Title="Home"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="MainPage" />
</Shell>

it can't work and I got the following error messages:

Error: Microsoft.Maui.Automation.ElementsNotFoundException: Elements not found matching query
   at Microsoft.Maui.Automation.Querying.DriverQuery.AutoWait(Int32 autoWaitMs, Int32 retryDelayMs, Boolean waitForNone)
   at Submission#9.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)

If it supports Shell and Shell navigation, how should I do for my UITest code?

Stuck in Windows tests

Would you take a minute to help a soul in pain?

Whilst Android works, my configuration does not work in Windows.
Using this:

driver = new AppDriverBuilder()
.AppId("com.companyname.samplemauiapp")
.AppFilename("C:\Users\mdelg\source\repos\Maui.UITesting\samples\SampleMauiApp\bin\Debug\net7.0-windows10.0.19041\win10-x64\SampleMauiApp.exe")
.DevicePlatform(Platform.Winappsdk)
.AutomationPlatform(Platform.Maui)
.Build();
}

I get this error:

System.InvalidOperationException: 'The system cannot find the file specified'

In this instruction
Session = new Lazy<WindowsDriver>(() =>
new WindowsDriver(new Uri("http://127.0.0.1:4723"), appCapabilities));

that in the debugger passes the first time and then throws the error after this instruction
await driver. Start();

Any idea? Is it configuration or Windows Application Driver (installed and using ve. 1.2.1.0)

Thanks in advance and I think your package could solve a great need for the Maui community.

InputText on Android switches out of app

I cloned the repo, built the app and updated the settings in Tests.cs to point to my APK and device (Samsung Galaxy Tab S5e on Android 11). I then created the test below and when I run the test it launches the app on the tablet but when attempting to perform InputText it switches out of the app and basically does a google search.

[Fact]
public async Task LoginTest()
{
await driver.Start();
await driver.AutomationId("entryUsername").InputText("xamarin");
await driver.AutomationId("entryPassword").InputText("1234");
await driver.AutomationId("buttonLogin").Tap();
}

image

Any suggestions as to what to do to try to troubleshoot this?

Any hope to have this further developed? Net 7 for example?

I tried to implement your nice package but my project is already running in .Net 7 and was more pain than pleasure. Had to abandon.

Was wondering if you have any plans to port it to .Net7 or have an option for UI test instead?

Thanks in advance

how do we start the server on android

Right now the server starts from that sample app, is there a way that you though of to start the server so that we can test any random app with it? I have cloned it and working on cli yaml runner but it doesn't work with other apps.

Project is dead?

Any news on the status of the project? Since there is no official solution for testing

Alternative that doesn't require an "agent" to be embedded in the application

Hello,

If my understanding is correct, in order to be able to test the application you'll need to include the agent in the application code itself (e.g., <ProjectReference Include="..\..\src\Agent\Agent.csproj" /> from here)

I'd say this is a significant drawback, since ideally you'd want to test exactly the same binary that you also manually smoked tested and that you'll ship on the App Store/Play Store, and you wouldn't want to include the agent in the store binary. Testing the same binary gives you increased confidence, as it reduces the risk introduced by the differences between the "test" binary and the store binary.

This is why Appium has been our tool of choice for a long time, because you test the same binary that you ship on the store.

Regards,
Cosmin

How to set up Xappium?

How to setup Xappium for testing a .Net Maui iOS app? Please help with step by step instructions.

Replace services with mocks in DI container

It would be great to test Maui application in isolation from backend in some cases. Therefore, the ability to replace services in DI container with mocks would be useful. Usually that applies to Http clients, but other things are possible as well.
I'm not sure if that's possible with the current approach though.
Are there any ideas how that could be achieved?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.