Skip to content

Commit

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

* Enabled 46th set of UITests migrated from XamarinUITest into Appium (dotnet#44)

* Migrated the Bugzilla44096, Issue10608 and 1414

* Migrated the Issues 11523, 2951 and 7167

* Addressed the feedbacks

* Addressed the feedbacks

* Modified the enabled tests

* Update Issue2951

* Migrated 4138

---------

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

* Added UITest images for Android and iOS platforms (dotnet#45)

* Migrated the Bugzilla44096, Issue10608 and 1414

* Migrated the Issues 11523, 2951 and 7167

* Addressed the feedbacks

* Addressed the feedbacks

* Modified the enabled tests

* Update Issue2951

* Migrated 4138

* Updated images for android and iOS

---------

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

* Added windows images and resolved test failures on CI

---------

Co-authored-by: nivetha-nagalingam <[email protected]>
  • Loading branch information
anandhan-rajagopal and nivetha-nagalingam authored Dec 14, 2024
1 parent c0bd0b3 commit 833856c
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 146 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 4138, "", PlatformAffected.iOS)]
[Issue(IssueTracker.Github, 4138, "[iOS] NavigationPage.TitleIcon no longer centered", PlatformAffected.iOS)]
public class Issue4138 : TestNavigationPage
{
protected override void Init()
{
ContentPage contentPage = new ContentPage();
ContentPage contentPage = new ContentPage() { Content = new Label(){ Text = "Content Page", AutomationId = "ContentPage"}};

NavigationPage.SetTitleIconImageSource(contentPage, "coffee.png");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
using NUnit.Framework;
#if TEST_FAILS_ON_WINDOWS //Pending Navigations still processing exception when navigating to the page on windows. Issue Link: https://github.com/dotnet/maui/issues/17608
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue10608 : _IssuesUITest
{
const string OpenLeftId = "OpenLeftId";
const string OpenRightId = "OpenRightId";
const string OpenTopId = "OpenTopId";
const string OpenBottomId = "OpenBottomId";
const string CloseId = "CloseId";
#if ANDROID
const string Tab1 = "TAB 1";
const string Tab2 = "TAB 2";
const string FlyoutItem6 = "Let me click for you";
#else
const string Tab1 = "Tab1AutomationId";
const string Tab2 = "Tab2AutomationId";
const string FlyoutItem6 = "FlyoutItem6";
#endif

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

public override string Issue => "[Bug] [Shell] [iOS] Locked flyout causes application to freezes when quickly switching between tabs";

// [Test]
// [Category(UITestCategories.Shell)]
// public void ShellWithTopTabsFreezesWhenNavigatingFlyoutItems()
// {
// App.Tap("FlyoutItem6");
// App.Tap("FlyoutItem0");
// for (int i = 0; i < 5; i++)
// {
// App.WaitForElement("Tab1AutomationId");
// App.WaitForElement("LearnMoreButton");
// App.Tap("FlyoutItem0");
// App.Tap("FlyoutItem1");
// App.Tap("FlyoutItem0");
// App.WaitForElement("LearnMoreButton");
// }

// App.WaitForElement("Tab1AutomationId");
// App.WaitForElement("LearnMoreButton");
// App.Tap("FlyoutItem1");
// App.WaitForElement("Tab2AutomationId");
// App.WaitForElement("LearnMoreButton");
// App.Tap("FlyoutItem0");
// App.WaitForElement("Tab1AutomationId");
// App.WaitForElement("LearnMoreButton");
// }
[Test]
[Category(UITestCategories.Shell)]
public void ShellWithTopTabsFreezesWhenNavigatingFlyoutItems()
{
App.Tap(FlyoutItem6);
App.Tap("FlyoutItem0");
for (int i = 0; i < 5; i++)
{
App.WaitForElement(Tab1);
App.WaitForElement("LearnMoreButton");
App.Tap("FlyoutItem0");
App.Tap("FlyoutItem1");
App.Tap("FlyoutItem0");
App.WaitForElement("LearnMoreButton");
}
App.WaitForElement(Tab1);
App.WaitForElement("LearnMoreButton");
App.Tap("FlyoutItem1");
App.WaitForElement(Tab2);
App.WaitForElement("LearnMoreButton");
App.Tap("FlyoutItem0");
App.WaitForElement(Tab1);
App.WaitForElement("LearnMoreButton");
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using NUnit.Framework;
#if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST
// This test is skipped on iOS and Catalyst due to potential flakiness.
// In the sample uses a delay which can cause the test to fail randomly.
// To maintain test reliability, we exclude this test on these platforms.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -12,13 +16,13 @@ public Issue11523(TestDevice testDevice) : base(testDevice)

public override string Issue => "[Bug] FlyoutBehavior.Disabled removes back-button from navbar";

// [Test]
// [Category(UITestCategories.Shell)]
// public void BackButtonStillVisibleWhenFlyoutBehaviorDisabled()
// {
// App.WaitForElement("PageLoaded");
// App.WaitForElement(BackButtonAutomationId);
// App.Tap(BackButtonAutomationId);
// App.WaitForElement(FlyoutIconAutomationId);
// }
}
[Test]
[Category(UITestCategories.Shell)]
public void BackButtonStillVisibleWhenFlyoutBehaviorDisabled()
{
App.WaitForElement("PageLoaded");
App.TapBackArrow();
App.WaitForFlyoutIcon(FlyoutIconAutomationId);
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_CATALYST //ScrollDown and ScrollUp are not working on MacCatalyst
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -12,15 +13,15 @@ public Issue1414(TestDevice testDevice) : base(testDevice)

public override string Issue => "InvalidCastException when scrolling and refreshing TableView";

// [Test]
// [Category(UITestCategories.TableView)]
// public void InvalidCastExceptionWhenScrollingAndRefreshingTableView()
// {
// App.Screenshot("Start G1414");
// var tableFrame = App.WaitForElement(q => q.Marked("TableView"))[0].Rect;
// App.ScrollForElement("* marked:'Row-4-24'", new Drag(tableFrame, Drag.Direction.BottomToTop, Drag.DragLength.Long));
// App.Screenshot("Scrolled to end without crashing!");
// App.ScrollForElement("* marked:'Row-0-0'", new Drag(tableFrame, Drag.Direction.TopToBottom, Drag.DragLength.Long));
// App.Screenshot("Scrolled to top without crashing!");
// }
}
[Test]
[Category(UITestCategories.TableView)]
public void InvalidCastExceptionWhenScrollingAndRefreshingTableView()
{
App.WaitForElement("TableView");
App.ScrollDown("TableView", ScrollStrategy.Gesture, 1.0, 50);
App.WaitForElement("Cell 4-24");
App.ScrollUp("TableView", ScrollStrategy.Gesture, 1.0, 30);
App.WaitForElement("Cell 0-0");
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,30 @@ public Issue2951(TestDevice testDevice) : base(testDevice)

public override string Issue => "On Android, button background is not updated when color changes ";

//[Test]
//[Category(UITestCategories.Button)]
//[FailsOnMauiIOS]
//public void Issue2951Test()
//{
// App.WaitForElement("Ready");
// var bt = App.WaitForElement(c => c.Marked("btnChangeStatus"));

// var buttons = App.QueryUntilPresent(() =>
// {
// var results = App.Query("btnChangeStatus");
// if (results.Length == 3)
// return results;

// return null;
// });

// Assert.That(buttons.Length, Is.EqualTo(3));
// App.Tap(c => c.Marked("btnChangeStatus").Index(1));

// buttons = App.QueryUntilPresent(() =>
// {
// var results = App.Query("btnChangeStatus");
// if ((results[1].Text ?? results[1].Label) == "B")
// return results;

// return null;
// });

// var text = buttons[1].Text ?? buttons[1].Label;
// Assert.That(text, Is.EqualTo("B"));
// App.Tap(c => c.Marked("btnChangeStatus").Index(1));

// buttons = App.QueryUntilPresent(() =>
// {
// var results = App.Query("btnChangeStatus");
// if (results.Length == 2)
// return results;

// return null;
// });

// Assert.That(buttons.Length, Is.EqualTo(2));
// //TODO: we should check the color of the button
// //var buttonTextColor = GetProperty<Color> ("btnChangeStatus", Button.BackgroundColorProperty);
// //Assert.AreEqual (Color.Pink, buttonTextColor);
//}
[Test]
[Category(UITestCategories.Button)]
public void Issue2951Test()
{
App.WaitForElement("Ready");

var initialButtonCount = App.FindElements("btnChangeStatus").Count();
Assert.That(initialButtonCount, Is.EqualTo(3));

var buttonToClick = App.FindElements("btnChangeStatus").ElementAt(1);
buttonToClick.Click();

Assert.That(buttonToClick.GetText(), Is.EqualTo("B"));

buttonToClick.Click();
var updatedButtonCount = App.FindElements("btnChangeStatus").Count();
Assert.That(updatedButtonCount, Is.EqualTo(2));

buttonToClick = App.FindElements("btnChangeStatus").ElementAt(1);
buttonToClick.Click();

// Use VerifyScreenshot to ensure the button background color has been updated properly
// This screenshot is captured to visually confirm that the background color has changed as expected
VerifyScreenshot();

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_WINDOWS // This test is specific to iOS because: Only on iOS is the title icon centered; on other platforms, it's aligned to the left.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -12,13 +13,12 @@ public Issue4138(TestDevice testDevice) : base(testDevice)

public override string Issue => "[iOS] NavigationPage.TitleIcon no longer centered";

//[Test]
//[Category(UITestCategories.Navigation)]
//[FailsOnIOS]
//public void TitleIconIsCentered()
//{
// var element = App.WaitForElement("coffee.png")[0];
// var rect = App.RootViewRect();
// Assert.AreEqual(element.Rect.CenterX, rect.CenterX);
//}
}
[Test]
[Category(UITestCategories.Navigation)]
public void TitleIconIsCentered()
{
App.WaitForElement("ContentPage");
VerifyScreenshot();
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_CATALYST //ScrollDown is not working on Catalyst
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -12,35 +13,31 @@ public Issue7167(TestDevice testDevice) : base(testDevice)

public override string Issue => "[Bug] improved observablecollection. a lot of collectionchanges. a reset is sent and listview scrolls to the top";

//[Test]
//[Category(UITestCategories.ListView)]
//const string ListViewId = "ListViewId";
//const string AddCommandID = "AddCommandID";
//const string ClearListCommandId = "ClearListCommandId";
//const string AddRangeCommandId = "AddRangeCommandId";
//const string AddRangeWithCleanCommandId = "AddRangeWithCleanCommandId";

const string ListViewId = "ListViewId";
const string AddRangeCommandId = "AddRangeCommandId";

//public void Issue7167Test()
//{
// // arrange
// // add items to the list and scroll down till item "25"
// App.Screenshot("Empty ListView");
// App.Tap(q => q.Button(AddRangeCommandId));
// App.Tap(q => q.Button(AddRangeCommandId));
// App.WaitForElement(c => c.Index(25).Property("Enabled", true));
// App.Print.Tree();
// App.ScrollDownTo(a => a.Marked("25").Property("text").Contains("25"),
// b => b.Marked(ListViewId), ScrollStrategy.Auto);
// App.WaitForElement(x => x.Marked("25"));

// // act
// // when adding additional items via a addrange and a CollectionChangedEventArgs.Action.Reset is sent
// // then the listview shouldnt reset or it should not scroll to the top
// App.Tap(q => q.Marked(AddRangeCommandId));
[Test]
[Category(UITestCategories.ListView)]
public void Issue7167Test()
{
// add items to the list and scroll down till item "23"
App.WaitForElement(AddRangeCommandId);
App.Tap(AddRangeCommandId);
App.Tap(AddRangeCommandId);

// No equivalent method found in Appium. Also this method is not necessary to validate the test case.
// App.Print.Tree();

App.ScrollDown(ListViewId, ScrollStrategy.Auto, 0.65, 200);
App.WaitForElement("23");

// when adding additional items via a addrange and a CollectionChangedEventArgs.Action.Reset is sent
// then the listview shouldnt reset or it should not scroll to the top
App.Tap(AddRangeCommandId);

// // assert
// // assert that item "25" is still visible
// var result = App.Query(x => x.Marked(ListViewId).Child().Marked("25"));
// Assert.That(result?.Length <= 0);
//}
}
// Verify that item "23" is still visible
App.WaitForElement("23");
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 833856c

Please sign in to comment.