jfversluis / Plugin.Maui.UITestHelpers

A set of helpers to support UI testing your .NET MAUI app and migration from Xamarin.UITest to Appium
MIT License
12 stars 4 forks source link

Exception is thrown when trying to call CloseApp on all platforms other than Windows #19

Closed skha83 closed 2 months ago

skha83 commented 2 months ago

When running UI tests on other targets than Windows the following exception will be thrown when trying to close an App with the App.CloseApp method:

System.MissingMethodException : Method not found: 'Void OpenQA.Selenium.Appium.AppiumDriver.CloseApp()'

This problem has already been fixed in the MAUI version of the code. Fixes can be found here:

https://github.com/dotnet/maui/blob/776dad91553c96ead0622da41b4c1ea8325b9fd0/src/TestUtils/src/UITest.Appium/Actions/AppiumLifecycleActions.cs#L64-L71 and here https://github.com/dotnet/maui/blob/776dad91553c96ead0622da41b4c1ea8325b9fd0/src/TestUtils/src/UITest.Appium/Actions/AppiumLifecycleActions.cs#L148-L154

Even though the given code path is never actually run on Android, it seems like it trying to use reflection to verify the CloseApp method exist on the AppiumDriver, which it only does on the Windows implementation.

Currently I'm using this method to make sure the app is restarted between each of my test cases, as I have not been able to find a way to do it by parsing native Appium options through this test framework