Skip to content

Commit

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

* Enabled 40th set of UITests from XamarinUITest into Appium (#38)

* Migrated Issues from XamarinUITest into Appium

* Migrated Issue ShellSearchHandlerItemSizing

* Added comments

* Modified Issue ShellFlyoutSizing

* Added issue link

* Updated migrated test cases

* Removed unwanted usings

---------

Co-authored-by: NafeelaNazhir <nafeela.nazhirhussain@syncfusion.com>

* Resolved Windows CI failure test case

* Enabled 40th set of UITests from XamarinUITest into Appium (#38)

* Migrated Issues from XamarinUITest into Appium

* Migrated Issue ShellSearchHandlerItemSizing

* Added comments

* Modified Issue ShellFlyoutSizing

* Added issue link

* Updated migrated test cases

* Removed unwanted usings

---------

Co-authored-by: NafeelaNazhir <nafeela.nazhirhussain@syncfusion.com>

* Resolved Windows CI failure test case

* Skips the tests which fails on CI.

---------

Co-authored-by: NafeelaNazhir <nafeela.nazhirhussain@syncfusion.com>
  • Loading branch information
anandhan-rajagopal and NafeelaNazhir authored Dec 16, 2024
1 parent cdbf93d commit 72de3c9
Show file tree
Hide file tree
Showing 7 changed files with 237 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class ShellFlyoutSizing : TestShell
{
protected override void Init()
{
FlyoutBehavior = FlyoutBehavior.Locked; //After tapping on items, the flyout closes on Windows. To ensure uniform behavior across platforms, set the FlyoutBehavior to Locked.
AddContentPage(new ContentPage()
{
Title = "Main Page",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ protected override void Init()
{
new Label()
{
Text = "Type into the search handler to display a list. Each item should be measured to the size of the content"
Text = "Type into the search handler to display a list. Each item should be measured to the size of the content",
AutomationId="Instructions"
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.None, 0, "Shell Title View Test",
[Issue(IssueTracker.None, 0, "Shell Title View Tests",
PlatformAffected.All)]
public class ShellTitleView : TestShell
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,53 @@ public ShellFlyoutSizing(TestDevice testDevice) : base(testDevice)

public override string Issue => "Shell Flyout Width and Height";

// TODO: IN the HostApp UI a line was commented out for the display density, need to reenable that first
//[Test]
//[Category(UITestCategories.Shell)]
//public void FlyoutHeightAndWidthResetsBackToOriginalSize()
//{
// App.WaitForElement("PageLoaded");
// this.ShowFlyout();
// var initialWidth = App.WaitForElement("FlyoutHeader")[0].Rect.Width;
// var initialHeight = App.WaitForElement("FlyoutFooter")[0].Rect.Y;
// TapInFlyout("ChangeFlyoutSizes", makeSureFlyoutStaysOpen: true);
// Assert.AreNotEqual(initialWidth, App.WaitForElement("FlyoutHeader")[0].Rect.Width);
// Assert.AreNotEqual(initialHeight, App.WaitForElement("FlyoutFooter")[0].Rect.Y);
// TapInFlyout("ResetFlyoutSizes", makeSureFlyoutStaysOpen: true);
// Assert.AreEqual(initialWidth, App.WaitForElement("FlyoutHeader")[0].Rect.Width);
// Assert.AreEqual(initialHeight, App.WaitForElement("FlyoutFooter")[0].Rect.Y);
//}

//[Test]
//[Category(UITestCategories.Shell)]
//public void FlyoutHeightAndWidthIncreaseAndDecreaseCorrectly()
//{
// App.WaitForElement("PageLoaded");
// this.ShowFlyout();
// TapInFlyout("ChangeFlyoutSizes", makeSureFlyoutStaysOpen: true);
// var initialWidth = App.WaitForElement("FlyoutHeader")[0].Rect.Width;
// var initialHeight = App.WaitForElement("FlyoutFooter")[0].Rect.Y;
// TapInFlyout("DecreaseFlyoutSizes", makeSureFlyoutStaysOpen: true);
// var newWidth = App.WaitForElement("FlyoutHeader")[0].Rect.Width;
// var newHeight = App.WaitForElement("FlyoutFooter")[0].Rect.Y;

// Assert.That(initialWidth - newWidth, Is.EqualTo(10).Within(1));
// Assert.That(initialHeight - newHeight, Is.EqualTo(10).Within(1));
//}
#if WINDOWS
const string ChangeFlyoutSizes="Change Height and Width";
const string ResetFlyoutSizes="Reset Height and Width";
const string DecreaseFlyoutSizes="Decrease Height and Width";
#else
const string ChangeFlyoutSizes = "ChangeFlyoutSizes";
const string ResetFlyoutSizes = "ResetFlyoutSizes";
const string DecreaseFlyoutSizes = "DecreaseFlyoutSizes";
#endif

#if ANDROID // Appium's GetRect method returns different sizes across platforms.
int difference = 26;
#elif IOS || WINDOWS
int difference = 10;
#elif MACCATALYST
int difference = 8;
#endif

[Test, Order(1)]
[Category(UITestCategories.Shell)]
public void FlyoutHeightAndWidthResetsBackToOriginalSize()
{
App.WaitForElement("PageLoaded");
var initialWidth = App.WaitForElement("FlyoutHeader").GetRect().Width;
var initialHeight = App.WaitForElement("FlyoutFooter").GetRect().Y;
App.Tap(ChangeFlyoutSizes);
Assert.That(App.WaitForElement("FlyoutHeader").GetRect().Width, Is.Not.EqualTo(initialWidth));
Assert.That(App.WaitForElement("FlyoutFooter").GetRect().Y, Is.Not.EqualTo(initialHeight));

App.Tap(ResetFlyoutSizes);
Assert.That(App.WaitForElement("FlyoutHeader").GetRect().Width, Is.EqualTo(initialWidth));
Assert.That(App.WaitForElement("FlyoutFooter").GetRect().Y, Is.EqualTo(initialHeight));
}

[Test, Order(2)]
[Category(UITestCategories.Shell)]
public void FlyoutHeightAndWidthIncreaseAndDecreaseCorrectly()
{
App.WaitForElement(ChangeFlyoutSizes);
App.Tap(ChangeFlyoutSizes);
var initialWidth = App.WaitForElement("FlyoutHeader").GetRect().Width;
var initialHeight = App.WaitForElement("FlyoutFooter").GetRect().Y;
App.Tap(DecreaseFlyoutSizes);
var newWidth = App.WaitForElement("FlyoutHeader").GetRect().Width;
var newHeight = App.WaitForElement("FlyoutFooter").GetRect().Y;
Assert.That(initialWidth - newWidth, Is.EqualTo(difference).Within(1));
Assert.That(initialHeight - newHeight, Is.EqualTo(difference).Within(1));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,68 +10,109 @@ public class ShellItemIsVisible : _IssuesUITest
public ShellItemIsVisible(TestDevice testDevice) : base(testDevice)
{
}
#if ANDROID
const string TitlePage = "ITEM TITLE PAGE";
const string TopTab1 = "TOP TAB 1";
const string TopTab2 = "TOP TAB 2";
#else
const string TitlePage="Item Title Page";
const string TopTab1="Top Tab 1";
const string TopTab2="Top Tab 2";
#endif

public override string Issue => "Shell Items IsVisible Test";

// [Test]
//public void FlyoutItemVisible()
//{
// App.Tap("ToggleFlyoutItem3");
// ShowFlyout();
// App.WaitForElement("Item2 Flyout");
// App.WaitForNoElement("Item3 Flyout");
//}

//[Test]
//public void HideActiveShellContent()
//{
// App.Tap("ToggleItem1");
// App.WaitForElement("Welcome to Tab 1");
// App.WaitForNoElement("ToggleItem1");
//}
[Test, Order(1)]
public void FlyoutItemVisible()
{
App.WaitForElement("ToggleFlyoutItem3");
App.WaitForElement("ToggleFlyoutItem3");
App.Tap("ToggleFlyoutItem3");
App.ShowFlyout();
App.WaitForElement("Item2 Flyout");
App.WaitForNoElement("Item3 Flyout");
}

//[Test]
//public void HideFlyoutItem()
//{
// App.WaitForElement("ToggleItem1");
// ShowFlyout();
// App.WaitForElement("Item2 Flyout");
// App.Tap("Item2 Flyout");
// App.Tap("AllVisible");
// App.Tap("ToggleItem2");
// ShowFlyout();
// App.WaitForElement("Item1 Flyout");
// App.WaitForNoElement("Item2 Flyout");
//}
[Test, Order(6)]
public void HideActiveShellContent()
{
App.WaitForElement("Item1 Flyout");
App.Tap("Item1 Flyout");
App.WaitForElementTillPageNavigationSettled(TitlePage);
TapTobTab(TitlePage);
App.WaitForElementTillPageNavigationSettled("ToggleItem1");
App.Tap("ToggleItem1");
App.WaitForElement("Welcome to Tab 1");
App.WaitForNoElement("ToggleItem1");
}

//[Test]
//public void ClearAndRecreateShellElements()
//{
// App.WaitForElement("ClearAndRecreate");
// App.Tap("ClearAndRecreate");
// App.WaitForElement("ClearAndRecreate");
// App.Tap("ClearAndRecreate");
//}

[Test, Order(5)]
public void HideFlyoutItem()
{
App.TapInShellFlyout("Item2 Flyout");
App.WaitForElement("ToggleItem1");
App.ShowFlyout();
App.WaitForElement("Item2 Flyout");
App.Tap("Item2 Flyout");
App.WaitForElementTillPageNavigationSettled("AllVisible");
App.Tap("AllVisible");
App.WaitForElementTillPageNavigationSettled("ToggleItem2");
App.Tap("ToggleItem2");
App.WaitForElementTillPageNavigationSettled(TitlePage);
App.ShowFlyout();
App.WaitForElement("Item1 Flyout");
App.WaitForNoElement("Item2 Flyout");
}

//[Test]
//public void ClearAndRecreateFromSecondaryPage()
//{
// App.WaitForElement("ClearAndRecreate");
// ShowFlyout();
// App.Tap("Item2 Flyout");
// App.Tap("ToggleItem1");
// App.Tap("ClearAndRecreate");
// App.Tap("Top Tab 2");
// App.Tap("Top Tab 1");
//}
#if !IOS // This test fails on CI for iOS. But in local it not replicate.
[Test, Order(2)]
public void ClearAndRecreateShellElements()
{
App.WaitForElement("Item1 Flyout");
App.Tap("Item1 Flyout");
App.WaitForElement("ClearAndRecreate");
App.Tap("ClearAndRecreate");
App.WaitForElementTillPageNavigationSettled("ClearAndRecreate");
App.Tap("ClearAndRecreate");
}
#endif

//[Test]
//public void ClearAndRecreateShellContent()
//{
// App.WaitForElement("ClearAndRecreateShellContent");
// App.Tap("ClearAndRecreateShellContent");
// App.WaitForElement("ClearAndRecreate");
// App.Tap("ClearAndRecreate");
//}
#if !WINDOWS // The test fails on Windows and throws an exception: "Navigation still processing" when tapping ClearAndRecreate after tapping ToggleItem1. MoreInformation:/~https://github.com/dotnet/maui/issues/17608
[Test, Order(4)]
public void ClearAndRecreateFromSecondaryPage()
{
App.WaitForElement("ClearAndRecreate");
App.ShowFlyout();
App.WaitForElement("Item2 Flyout");
App.Tap("Item2 Flyout");
App.WaitForElementTillPageNavigationSettled("ToggleItem1");
App.Tap("ToggleItem1");
App.WaitForElementTillPageNavigationSettled("ClearAndRecreate");
App.Tap("ClearAndRecreate");
App.WaitForElementTillPageNavigationSettled(TopTab2);
App.Tap(TopTab2);
App.WaitForElementTillPageNavigationSettled(TopTab1);
App.Tap(TopTab1);
}
#endif
[Test, Order(3)]
public void ClearAndRecreateShellContent()
{
#if IOS // TODO: Remove this once enabled the test order 2 in iOS
App.WaitForElement("Item1 Flyout");
App.Tap("Item1 Flyout");
#endif
App.WaitForElementTillPageNavigationSettled("ClearAndRecreateShellContent");
App.Tap("ClearAndRecreateShellContent");
App.WaitForElement("ClearAndRecreate");
App.Tap("ClearAndRecreate");
}
void TapTobTab(string tab)
{
#if WINDOWS
App.Tap("navViewItem");
#endif
App.Tap(tab);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NUnit.Framework;
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_CATALYST // In Android and Catalyst AutomationId is not working for SearchHandler, in Windows searchresults was not shown More Information: /~https://github.com/dotnet/maui/issues/26477
using UITest.Appium;
using NUnit.Framework;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;
Expand All @@ -12,13 +13,15 @@ public ShellSearchHandlerItemSizing(TestDevice testDevice) : base(testDevice)

public override string Issue => "Shell Search Handler Item Sizing";

//[Test]
//[Category(UITestCategories.Shell)]
//public void SearchHandlerSizesCorrectly()
//{
// App.WaitForElement("SearchHandler");
// App.EnterText("SearchHandler", "Hello");
// var contentSize = App.WaitForElement("searchresult")[0].Rect;
// Assert.Less(contentSize.Height, 100);
//}
}
[Test]
[Category(UITestCategories.Shell)]
public void SearchHandlerSizesCorrectly()
{
App.WaitForElement("Instructions");
App.EnterText(AppiumQuery.ByXPath("//XCUIElementTypeSearchField"),"Hello");
var contentSize = App.WaitForElement("searchresult").GetRect();
Assert.That(contentSize.Height, Is.LessThan(100));

}
}
#endif
Loading

0 comments on commit 72de3c9

Please sign in to comment.