Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Testing] Fix flaky UITests failing sometimes 2 #27154

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue2354.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ protected override void Init()
{
var presidents = new List<President>();

presidents.Add(new President($"Presidente 44", 1, $"https://github.com/dotnet/maui/blob/main/src/Compatibility/ControlGallery/src/Android/Resources/drawable/Fruits.jpg?raw=true"));
presidents.Add(new President($"Presidente 43", 2, $"https://github.com/dotnet/maui/blob/main/src/Compatibility/ControlGallery/src/Android/Resources/drawable/person.png?raw=true"));
presidents.Add(new President($"Presidente 42", 3, $"https://github.com/dotnet/maui/blob/main/src/Compatibility/ControlGallery/src/Android/Resources/drawable/photo.jpg?raw=true"));
presidents.Add(new President($"Presidente 41", 4, $"https://github.com/dotnet/maui/blob/main/src/Compatibility/ControlGallery/src/Android/Resources/drawable/FlowerBuds.jpg?raw=true"));
presidents.Add(new President($"Presidente 40", 5, $"https://github.com/dotnet/maui/blob/main/src/Compatibility/ControlGallery/src/Android/Resources/drawable/games.png?raw=true"));
presidents.Add(new President($"Presidente 39", 6, $"https://github.com/dotnet/maui/blob/main/src/Compatibility/ControlGallery/src/Android/Resources/drawable/gear.png?raw=true"));
presidents.Add(new President($"Presidente 38", 7, $"https://github.com/dotnet/maui/blob/main/src/Compatibility/ControlGallery/src/Android/Resources/drawable/coffee.png?raw=true"));
presidents.Add(new President($"Presidente 37", 8, $"https://github.com/dotnet/maui/blob/main/src/Compatibility/ControlGallery/src/Android/Resources/drawable/xamarinstore.jpg?raw=true"));
presidents.Add(new President($"Presidente 36", 9, $"https://github.com/dotnet/maui/blob/main/src/Compatibility/ControlGallery/src/Android/Resources/drawable/oasis.jpg?raw=true"));
presidents.Add(new President($"Presidente 35", 10, $"https://github.com/dotnet/maui/blob/main/src/Compatibility/ControlGallery/src/Android/Resources/drawable/Vegetables.jpg?raw=true"));
presidents.Add(new President($"Presidente 44", 1, $"https://github.com/dotnet/maui/blob/main/src/Controls/tests/TestCases.HostApp/Resources/Images/avatar.png?raw=true"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed the Legacy Gallery #26068 and the test was using images from that gallery. For that reason, was failing.

presidents.Add(new President($"Presidente 43", 2, $"https://github.com/dotnet/maui/blob/main/src/Controls/tests/TestCases.HostApp/Resources/Images/oasis.jpg?raw=true"));
presidents.Add(new President($"Presidente 42", 3, $"https://github.com/dotnet/maui/blob/main/src/Controls/tests/TestCases.HostApp/Resources/Images/photo21314.jpg?raw=true"));
presidents.Add(new President($"Presidente 41", 4, $"https://github.com/dotnet/maui/blob/main/src/Controls/tests/TestCases.HostApp/Resources/Images/groceries.png?raw=true"));
presidents.Add(new President($"Presidente 40", 5, $"https://github.com/dotnet/maui/blob/main/src/Controls/tests/TestCases.HostApp/Resources/Images/avatar.png?raw=true"));
presidents.Add(new President($"Presidente 39", 6, $"https://github.com/dotnet/maui/blob/main/src/Controls/tests/TestCases.HostApp/Resources/Images/oasis.jpg?raw=true"));
presidents.Add(new President($"Presidente 38", 7, $"https://github.com/dotnet/maui/blob/main/src/Controls/tests/TestCases.HostApp/Resources/Images/photo21314.jpg?raw=true"));
presidents.Add(new President($"Presidente 37", 8, $"https://github.com/dotnet/maui/blob/main/src/Controls/tests/TestCases.HostApp/Resources/Images/groceries.png?raw=true"));
presidents.Add(new President($"Presidente 36", 9, $"https://github.com/dotnet/maui/blob/main/src/Controls/tests/TestCases.HostApp/Resources/Images/avatar.png?raw=true"));
presidents.Add(new President($"Presidente 35", 10, $"https://github.com/dotnet/maui/blob/main/src/Controls/tests/TestCases.HostApp/Resources/Images/oasis.jpg?raw=true"));

var header = new Label
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public CollectionViewHeaderAndFooterTests(TestDevice device)
{
}

[Test]
#if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST // Header not rendering issue: https://github.com/dotnet/maui/issues/27177
[Test]
[Category(UITestCategories.CollectionView)]
public void HeaderFooterStringWorks()
{
Expand All @@ -28,8 +29,9 @@ public void HeaderFooterStringWorks()
App.WaitForElement("Just a string as a header");
App.WaitForElement("This footer is also a string");
}
#endif

[Test]
[Test]
[Category(UITestCategories.CollectionView)]
public void HeaderFooterViewWorks()
{
Expand Down Expand Up @@ -72,7 +74,7 @@ public void HeaderFooterGridWorks()
VerifyScreenshot();
}

#if TEST_FAILS_ON_IOS
#if TEST_FAILS_ON_IOS
// The screenshot that's currently generated for this test is wrong
// So, we're ignoring this test due to it causing confusion when other changes
// cause this test to fail.
Expand All @@ -93,7 +95,7 @@ public void HeaderFooterGridHorizontalWorks()

VerifyScreenshot();
}
#endif
#endif
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST // Header not rendering issue: https://github.com/dotnet/maui/issues/27177
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -23,4 +24,5 @@ public void CollectionViewHeaderTemplateAndFooterTemplateDontWork()
App.WaitForElement("FooterLabel");
}
}
}
}
#endif
4 changes: 2 additions & 2 deletions src/TestUtils/src/UITest.Appium/HelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,7 @@ public static void TapBackArrow(this IApp app, string customBackButtonIdentifier
/// <param name="query">The custom IQuery for the back button.</param>
public static void TapBackArrow(this IApp app, IQuery query)
{
app.Tap(query);
app.WaitForElement(query).Tap();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait to find the Back Button before try to tap it.

}

/// <summary>
Expand Down Expand Up @@ -1899,7 +1899,7 @@ static IQuery GetDefaultBackArrowQuery(IApp app)
{
return app switch
{
AppiumAndroidApp _ => AppiumQuery.ByXPath("//android.widget.ImageButton[@content-desc='Navigate up']"),
AppiumAndroidApp _ => AppiumQuery.ByXPath($"//android.widget.LinearLayout[@resource-id=\"{app.GetAppId()}:id/navigationlayout_appbar\"]/android.view.ViewGroup/*[1]"),
AppiumIOSApp _ => AppiumQuery.ByAccessibilityId("Back"),
AppiumCatalystApp _ => AppiumQuery.ByAccessibilityId("Back"),
AppiumWindowsApp _ => AppiumQuery.ByAccessibilityId("NavigationViewBackButton"),
Expand Down
Loading