Skip to content

Commit 72de3c9

Browse files
Anandhan RajagopalNafeelaNazhir
andauthored
[Testing] Enabling ported UITests from Xamarin.UITests to Appium - 40 (#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 <[email protected]> * 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 <[email protected]> * Resolved Windows CI failure test case * Skips the tests which fails on CI. --------- Co-authored-by: NafeelaNazhir <[email protected]>
1 parent cdbf93d commit 72de3c9

File tree

7 files changed

+237
-149
lines changed

7 files changed

+237
-149
lines changed

src/Controls/tests/TestCases.HostApp/Issues/XFIssue/ShellFlyoutSizing.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class ShellFlyoutSizing : TestShell
66
{
77
protected override void Init()
88
{
9+
FlyoutBehavior = FlyoutBehavior.Locked; //After tapping on items, the flyout closes on Windows. To ensure uniform behavior across platforms, set the FlyoutBehavior to Locked.
910
AddContentPage(new ContentPage()
1011
{
1112
Title = "Main Page",

src/Controls/tests/TestCases.HostApp/Issues/XFIssue/ShellSearchHandlerItemSizing.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ protected override void Init()
1919
{
2020
new Label()
2121
{
22-
Text = "Type into the search handler to display a list. Each item should be measured to the size of the content"
22+
Text = "Type into the search handler to display a list. Each item should be measured to the size of the content",
23+
AutomationId="Instructions"
2324
}
2425
};
2526
}

src/Controls/tests/TestCases.HostApp/Issues/XFIssue/ShellTitleView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Maui.Controls.Sample.Issues;
22

3-
[Issue(IssueTracker.None, 0, "Shell Title View Test",
3+
[Issue(IssueTracker.None, 0, "Shell Title View Tests",
44
PlatformAffected.All)]
55
public class ShellTitleView : TestShell
66
{

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/ShellFlyoutSizing.cs

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,53 @@ public ShellFlyoutSizing(TestDevice testDevice) : base(testDevice)
1212

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

15-
// TODO: IN the HostApp UI a line was commented out for the display density, need to reenable that first
16-
//[Test]
17-
//[Category(UITestCategories.Shell)]
18-
//public void FlyoutHeightAndWidthResetsBackToOriginalSize()
19-
//{
20-
// App.WaitForElement("PageLoaded");
21-
// this.ShowFlyout();
22-
// var initialWidth = App.WaitForElement("FlyoutHeader")[0].Rect.Width;
23-
// var initialHeight = App.WaitForElement("FlyoutFooter")[0].Rect.Y;
24-
// TapInFlyout("ChangeFlyoutSizes", makeSureFlyoutStaysOpen: true);
25-
// Assert.AreNotEqual(initialWidth, App.WaitForElement("FlyoutHeader")[0].Rect.Width);
26-
// Assert.AreNotEqual(initialHeight, App.WaitForElement("FlyoutFooter")[0].Rect.Y);
27-
// TapInFlyout("ResetFlyoutSizes", makeSureFlyoutStaysOpen: true);
28-
// Assert.AreEqual(initialWidth, App.WaitForElement("FlyoutHeader")[0].Rect.Width);
29-
// Assert.AreEqual(initialHeight, App.WaitForElement("FlyoutFooter")[0].Rect.Y);
30-
//}
31-
32-
//[Test]
33-
//[Category(UITestCategories.Shell)]
34-
//public void FlyoutHeightAndWidthIncreaseAndDecreaseCorrectly()
35-
//{
36-
// App.WaitForElement("PageLoaded");
37-
// this.ShowFlyout();
38-
// TapInFlyout("ChangeFlyoutSizes", makeSureFlyoutStaysOpen: true);
39-
// var initialWidth = App.WaitForElement("FlyoutHeader")[0].Rect.Width;
40-
// var initialHeight = App.WaitForElement("FlyoutFooter")[0].Rect.Y;
41-
// TapInFlyout("DecreaseFlyoutSizes", makeSureFlyoutStaysOpen: true);
42-
// var newWidth = App.WaitForElement("FlyoutHeader")[0].Rect.Width;
43-
// var newHeight = App.WaitForElement("FlyoutFooter")[0].Rect.Y;
44-
45-
// Assert.That(initialWidth - newWidth, Is.EqualTo(10).Within(1));
46-
// Assert.That(initialHeight - newHeight, Is.EqualTo(10).Within(1));
47-
//}
15+
#if WINDOWS
16+
const string ChangeFlyoutSizes="Change Height and Width";
17+
const string ResetFlyoutSizes="Reset Height and Width";
18+
const string DecreaseFlyoutSizes="Decrease Height and Width";
19+
#else
20+
const string ChangeFlyoutSizes = "ChangeFlyoutSizes";
21+
const string ResetFlyoutSizes = "ResetFlyoutSizes";
22+
const string DecreaseFlyoutSizes = "DecreaseFlyoutSizes";
23+
#endif
24+
25+
#if ANDROID // Appium's GetRect method returns different sizes across platforms.
26+
int difference = 26;
27+
#elif IOS || WINDOWS
28+
int difference = 10;
29+
#elif MACCATALYST
30+
int difference = 8;
31+
#endif
32+
33+
[Test, Order(1)]
34+
[Category(UITestCategories.Shell)]
35+
public void FlyoutHeightAndWidthResetsBackToOriginalSize()
36+
{
37+
App.WaitForElement("PageLoaded");
38+
var initialWidth = App.WaitForElement("FlyoutHeader").GetRect().Width;
39+
var initialHeight = App.WaitForElement("FlyoutFooter").GetRect().Y;
40+
App.Tap(ChangeFlyoutSizes);
41+
Assert.That(App.WaitForElement("FlyoutHeader").GetRect().Width, Is.Not.EqualTo(initialWidth));
42+
Assert.That(App.WaitForElement("FlyoutFooter").GetRect().Y, Is.Not.EqualTo(initialHeight));
43+
44+
App.Tap(ResetFlyoutSizes);
45+
Assert.That(App.WaitForElement("FlyoutHeader").GetRect().Width, Is.EqualTo(initialWidth));
46+
Assert.That(App.WaitForElement("FlyoutFooter").GetRect().Y, Is.EqualTo(initialHeight));
47+
}
48+
49+
[Test, Order(2)]
50+
[Category(UITestCategories.Shell)]
51+
public void FlyoutHeightAndWidthIncreaseAndDecreaseCorrectly()
52+
{
53+
App.WaitForElement(ChangeFlyoutSizes);
54+
App.Tap(ChangeFlyoutSizes);
55+
var initialWidth = App.WaitForElement("FlyoutHeader").GetRect().Width;
56+
var initialHeight = App.WaitForElement("FlyoutFooter").GetRect().Y;
57+
App.Tap(DecreaseFlyoutSizes);
58+
var newWidth = App.WaitForElement("FlyoutHeader").GetRect().Width;
59+
var newHeight = App.WaitForElement("FlyoutFooter").GetRect().Y;
60+
Assert.That(initialWidth - newWidth, Is.EqualTo(difference).Within(1));
61+
Assert.That(initialHeight - newHeight, Is.EqualTo(difference).Within(1));
62+
63+
}
4864
}

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/ShellItemIsVisible.cs

Lines changed: 97 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,68 +10,109 @@ public class ShellItemIsVisible : _IssuesUITest
1010
public ShellItemIsVisible(TestDevice testDevice) : base(testDevice)
1111
{
1212
}
13+
#if ANDROID
14+
const string TitlePage = "ITEM TITLE PAGE";
15+
const string TopTab1 = "TOP TAB 1";
16+
const string TopTab2 = "TOP TAB 2";
17+
#else
18+
const string TitlePage="Item Title Page";
19+
const string TopTab1="Top Tab 1";
20+
const string TopTab2="Top Tab 2";
21+
#endif
1322

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

16-
// [Test]
17-
//public void FlyoutItemVisible()
18-
//{
19-
// App.Tap("ToggleFlyoutItem3");
20-
// ShowFlyout();
21-
// App.WaitForElement("Item2 Flyout");
22-
// App.WaitForNoElement("Item3 Flyout");
23-
//}
24-
25-
//[Test]
26-
//public void HideActiveShellContent()
27-
//{
28-
// App.Tap("ToggleItem1");
29-
// App.WaitForElement("Welcome to Tab 1");
30-
// App.WaitForNoElement("ToggleItem1");
31-
//}
25+
[Test, Order(1)]
26+
public void FlyoutItemVisible()
27+
{
28+
App.WaitForElement("ToggleFlyoutItem3");
29+
App.WaitForElement("ToggleFlyoutItem3");
30+
App.Tap("ToggleFlyoutItem3");
31+
App.ShowFlyout();
32+
App.WaitForElement("Item2 Flyout");
33+
App.WaitForNoElement("Item3 Flyout");
34+
}
3235

33-
//[Test]
34-
//public void HideFlyoutItem()
35-
//{
36-
// App.WaitForElement("ToggleItem1");
37-
// ShowFlyout();
38-
// App.WaitForElement("Item2 Flyout");
39-
// App.Tap("Item2 Flyout");
40-
// App.Tap("AllVisible");
41-
// App.Tap("ToggleItem2");
42-
// ShowFlyout();
43-
// App.WaitForElement("Item1 Flyout");
44-
// App.WaitForNoElement("Item2 Flyout");
45-
//}
36+
[Test, Order(6)]
37+
public void HideActiveShellContent()
38+
{
39+
App.WaitForElement("Item1 Flyout");
40+
App.Tap("Item1 Flyout");
41+
App.WaitForElementTillPageNavigationSettled(TitlePage);
42+
TapTobTab(TitlePage);
43+
App.WaitForElementTillPageNavigationSettled("ToggleItem1");
44+
App.Tap("ToggleItem1");
45+
App.WaitForElement("Welcome to Tab 1");
46+
App.WaitForNoElement("ToggleItem1");
47+
}
4648

47-
//[Test]
48-
//public void ClearAndRecreateShellElements()
49-
//{
50-
// App.WaitForElement("ClearAndRecreate");
51-
// App.Tap("ClearAndRecreate");
52-
// App.WaitForElement("ClearAndRecreate");
53-
// App.Tap("ClearAndRecreate");
54-
//}
5549

50+
[Test, Order(5)]
51+
public void HideFlyoutItem()
52+
{
53+
App.TapInShellFlyout("Item2 Flyout");
54+
App.WaitForElement("ToggleItem1");
55+
App.ShowFlyout();
56+
App.WaitForElement("Item2 Flyout");
57+
App.Tap("Item2 Flyout");
58+
App.WaitForElementTillPageNavigationSettled("AllVisible");
59+
App.Tap("AllVisible");
60+
App.WaitForElementTillPageNavigationSettled("ToggleItem2");
61+
App.Tap("ToggleItem2");
62+
App.WaitForElementTillPageNavigationSettled(TitlePage);
63+
App.ShowFlyout();
64+
App.WaitForElement("Item1 Flyout");
65+
App.WaitForNoElement("Item2 Flyout");
66+
}
5667

57-
//[Test]
58-
//public void ClearAndRecreateFromSecondaryPage()
59-
//{
60-
// App.WaitForElement("ClearAndRecreate");
61-
// ShowFlyout();
62-
// App.Tap("Item2 Flyout");
63-
// App.Tap("ToggleItem1");
64-
// App.Tap("ClearAndRecreate");
65-
// App.Tap("Top Tab 2");
66-
// App.Tap("Top Tab 1");
67-
//}
68+
#if !IOS // This test fails on CI for iOS. But in local it not replicate.
69+
[Test, Order(2)]
70+
public void ClearAndRecreateShellElements()
71+
{
72+
App.WaitForElement("Item1 Flyout");
73+
App.Tap("Item1 Flyout");
74+
App.WaitForElement("ClearAndRecreate");
75+
App.Tap("ClearAndRecreate");
76+
App.WaitForElementTillPageNavigationSettled("ClearAndRecreate");
77+
App.Tap("ClearAndRecreate");
78+
}
79+
#endif
6880

69-
//[Test]
70-
//public void ClearAndRecreateShellContent()
71-
//{
72-
// App.WaitForElement("ClearAndRecreateShellContent");
73-
// App.Tap("ClearAndRecreateShellContent");
74-
// App.WaitForElement("ClearAndRecreate");
75-
// App.Tap("ClearAndRecreate");
76-
//}
81+
#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
82+
[Test, Order(4)]
83+
public void ClearAndRecreateFromSecondaryPage()
84+
{
85+
App.WaitForElement("ClearAndRecreate");
86+
App.ShowFlyout();
87+
App.WaitForElement("Item2 Flyout");
88+
App.Tap("Item2 Flyout");
89+
App.WaitForElementTillPageNavigationSettled("ToggleItem1");
90+
App.Tap("ToggleItem1");
91+
App.WaitForElementTillPageNavigationSettled("ClearAndRecreate");
92+
App.Tap("ClearAndRecreate");
93+
App.WaitForElementTillPageNavigationSettled(TopTab2);
94+
App.Tap(TopTab2);
95+
App.WaitForElementTillPageNavigationSettled(TopTab1);
96+
App.Tap(TopTab1);
97+
}
98+
#endif
99+
[Test, Order(3)]
100+
public void ClearAndRecreateShellContent()
101+
{
102+
#if IOS // TODO: Remove this once enabled the test order 2 in iOS
103+
App.WaitForElement("Item1 Flyout");
104+
App.Tap("Item1 Flyout");
105+
#endif
106+
App.WaitForElementTillPageNavigationSettled("ClearAndRecreateShellContent");
107+
App.Tap("ClearAndRecreateShellContent");
108+
App.WaitForElement("ClearAndRecreate");
109+
App.Tap("ClearAndRecreate");
110+
}
111+
void TapTobTab(string tab)
112+
{
113+
#if WINDOWS
114+
App.Tap("navViewItem");
115+
#endif
116+
App.Tap(tab);
117+
}
77118
}
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using NUnit.Framework;
1+
#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
22
using UITest.Appium;
3+
using NUnit.Framework;
34
using UITest.Core;
45

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

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

15-
//[Test]
16-
//[Category(UITestCategories.Shell)]
17-
//public void SearchHandlerSizesCorrectly()
18-
//{
19-
// App.WaitForElement("SearchHandler");
20-
// App.EnterText("SearchHandler", "Hello");
21-
// var contentSize = App.WaitForElement("searchresult")[0].Rect;
22-
// Assert.Less(contentSize.Height, 100);
23-
//}
24-
}
16+
[Test]
17+
[Category(UITestCategories.Shell)]
18+
public void SearchHandlerSizesCorrectly()
19+
{
20+
App.WaitForElement("Instructions");
21+
App.EnterText(AppiumQuery.ByXPath("//XCUIElementTypeSearchField"),"Hello");
22+
var contentSize = App.WaitForElement("searchresult").GetRect();
23+
Assert.That(contentSize.Height, Is.LessThan(100));
24+
25+
}
26+
}
27+
#endif

0 commit comments

Comments
 (0)