Skip to content

Commit

Permalink
[Testing] Enabling ported UITests from Xamarin.UITests to Appium - 14 (
Browse files Browse the repository at this point in the history
…dotnet#25989)

* Enabled UI Tests form XamarinUITests into Appium (dotnet#7)

* Migrated the Issues 1023, 12126, 9006, 6127.

* Migrated the Issue1323

* updated the test migration changes

* Reverted unwanted changes

---------

Co-authored-by: nivetha-nagalingam <[email protected]>

* Update Issue6127

* updated the review changes

* Update 9006.cs

* Resolved CI failure

* Updated HelperExtensions.cs

* Update HelperExtensions.cs

* Fixed the CI failure on Android

* Skip failed tests on CI

---------

Co-authored-by: nivetha-nagalingam <[email protected]>
  • Loading branch information
anandhan-rajagopal and nivetha-nagalingam authored Dec 14, 2024
1 parent 833856c commit d621121
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 91 deletions.
21 changes: 19 additions & 2 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue9006.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Issue9006 : TestShell
{
protected override void Init()
{
Routing.RegisterRoute("Issue9006_ContentPage", typeof(ContentPage));
Routing.RegisterRoute("Issue9006_ContentPage", typeof(IntermediatePage));
Routing.RegisterRoute("Issue9006_FinalPage", typeof(ContentPage));

var contentPage = AddBottomTab("Tab 1");
Expand All @@ -25,7 +25,7 @@ protected override void Init()
button = new Button()
{
Text = "Click Me",
AutomationId = "Click Me",
AutomationId = "ClickMe",
Command = new Command(async () =>
{
await GoToAsync("Issue9006_ContentPage");
Expand Down Expand Up @@ -54,5 +54,22 @@ protected override void Init()
}
};
}

public class IntermediatePage : ContentPage
{
public IntermediatePage()
{
Content = new StackLayout()
{
Children =
{
new Label()
{
Text = "This is the intermediate page"
}
}
};
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public LandingPage1023()
Label = new Label
{
Text = "Counter: " + Counter,
AutomationId = "Counter",
HorizontalTextAlignment = TextAlignment.Center,
VerticalTextAlignment = TextAlignment.Center
};
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
#if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS // Getting an OpenQA.Selenium.InvalidSelectorException : XQueryError:6 - "invalid type" in Line: 32. Using timeout also not works.
// On iOS test consistently crashes on CI, but passes locally. Adding failure for iOS to ensure CI stability.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;
Expand All @@ -7,6 +8,15 @@ namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue9006 : _IssuesUITest
{
#if ANDROID
const string Back = "";
const string Tab1 = "";
#else
const string Back = "Back";
const string Tab1 = "Tab 1";
#endif
const string ClickMe = "ClickMe";
const string FinalLabel = "FinalLabel";
public Issue9006(TestDevice testDevice) : base(testDevice)
{
}
Expand All @@ -18,14 +28,17 @@ public Issue9006(TestDevice testDevice) : base(testDevice)
[Category(UITestCategories.Compatibility)]
public void ClickingOnTabToPopToRootDoesntBreakNavigation()
{
this.IgnoreIfPlatforms([TestDevice.Android, TestDevice.Mac, TestDevice.Windows]);
App.Tap("Click Me");
App.WaitForElement("FinalLabel");
App.Tap("Tab1AutomationId");
App.Tap("Click Me");
App.WaitForNoElement("Success");
App.WaitForElement(ClickMe);
App.Tap(ClickMe);
App.WaitForElement(FinalLabel);
App.TapBackArrow(Back);
App.WaitForElement("This is the intermediate page");
App.TapBackArrow(Tab1);
App.WaitForElement(ClickMe);
App.Tap(ClickMe);
App.WaitForElement(FinalLabel);
Assert.That(App.WaitForElement(FinalLabel)?.GetText(), Is.EqualTo("Success"));
}
}
}
*/
#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if IOS
using NUnit.Framework;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -13,26 +12,28 @@ public Issue1023_Forms(TestDevice testDevice) : base(testDevice)

public override string Issue => "Automate GC checks of picker disposals";

// [Test]
// [Category(UITestCategories.Picker)]
// [FailsOnIOS]
// public void Bugzilla1023Test()
// {
// for (var n = 0; n < 10; n++)
// {
// App.WaitForElement(q => q.Marked("Push"));
// App.Tap(q => q.Marked("Push"));

// App.WaitForElement(q => q.Marked("ListView"));
// App.Back();
// }

// // At this point, the counter can be any value, but it's most likely not zero.
// // Invoking GC once is enough to clean up all garbage data and set counter to zero
// App.WaitForElement(q => q.Marked("GC"));
// App.Tap(q => q.Marked("GC"));

// App.WaitForElement(q => q.Marked("Counter: 0"));
// }
}
#endif
[Test]
[Category(UITestCategories.Picker)]
public void Bugzilla1023Test()
{
for (var n = 0; n < 10; n++)
{
App.WaitForElement("Push");
App.Tap("Push");

App.WaitForElement("ListView");
#if IOS //Getting null reference exception while tap the back button without WaitForElement in iOS.
App.WaitForElement("Back");
#endif
App.TapBackArrow();

}

// At this point, the counter can be any value, but it's most likely not zero.
// Invoking GC once is enough to clean up all garbage data and set counter to zero
App.WaitForElement("GC");
App.Tap("GC");

Assert.That(App.WaitForElement("Counter").GetText(), Is.EqualTo("Counter: 0"));
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
using NUnit.Framework;
#if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS // Secondary ToolBar still not supported of iOS and Catalyst https://github.com/dotnet/maui/issues/815
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue6127 : _IssuesUITest
{

public Issue6127(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "[Bug] ToolbarItem Order property ignored";

//[Test]
//[Category(UITestCategories.ToolbarItem)]
//public void Issue6127Test()
//{
// App.WaitForElement(PrimaryToolbarIcon);

// App.Tap("More options");
// App.WaitForElement(SecondaryToolbarIcon);

// App.Screenshot("There is a secondary toolbar menu and item");
//}
}
[Test]
[Category(UITestCategories.ToolbarItem)]
public void Issue6127Test()
{
//AutomationId for ToolBarIcon is not works in android
#if ANDROID
App.WaitForElement(AppiumQuery.ByXPath("//android.widget.Button[@content-desc='PrimaryToolbarIcon']"));
#else
App.WaitForElement("PrimaryToolbarIcon");
#endif
App.TapMoreButton();
App.WaitForElement("Coffee");
}
}
#endif
2 changes: 1 addition & 1 deletion src/TestUtils/src/UITest.Appium/HelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2113,4 +2113,4 @@ public static void SetTestConfigurationArg(this IConfig config, string key, stri
config.SetProperty("TestConfigurationArgs", startupArg);
}
}
}
}

0 comments on commit d621121

Please sign in to comment.