Repository: dotnet/maui
File: src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue18193.cs (C#)

Code before:
﻿using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
	public class Issue18193 : _IssuesUITest
	{
		public override string Issue => "[iOS] Navigation doesn't work on sixth tab in shell";

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

		[Test]
		[Category(UITestCategories.Shell)]
		public void ShellNavigationShouldWorkInMoreTab()
		{
			App.WaitForElementTillPageNavigationSettled("NavigationToPageSixthButton");
			App.Tap("NavigationToPageSixthButton");
			App.WaitForElementTillPageNavigationSettled("NavigateToDetailButton");
			App.Tap("NavigateToDetailButton");
			App.WaitForElementTillPageNavigationSettled("NavigateBackButton");
			App.Tap("NavigateBackButton");
			App.WaitForElementTillPageNavigationSettled("NavigateToPageTwoButton");
			App.Tap("NavigateToPageTwoButton");
			App.WaitForElementTillPageNavigationSettled("NavigateToPageFiveButton");
			App.Tap("NavigateToPageFiveButton");
			App.WaitForElementTillPageNavigationSettled("More");
			App.Tap("More");
		}
	}
}

Review comment (refactor):
**ShellNavigationShouldWorkInMoreTab** is gaining on Mac:

```
   at UITest.Appium.HelperExtensions.Wait(Func`1 query, Func`2 satisfactory, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2530
   at UITest.Appium.HelperExtensions.WaitForAtLeastOne(Func`1 query, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2547
   at UITest.Appium.HelperExtensions.WaitForElement(IApp app, IQuery query, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 777
   at UITest.Appium.HelperExtensions.WaitForElementTillPageNavigationSettled(IApp app, String elementId, Nullable`1 timeout) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2181
   at Microsoft.Maui.TestCases.Tests.Issues.Issue18193.ShellNavigationShouldWorkInMoreTab() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue18193.cs:line 23
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
```

Code after:
﻿using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
	public class Issue18193 : _IssuesUITest
	{
		public override string Issue => "[iOS] Navigation doesn't work on sixth tab in shell";

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

		[Test]
		[Category(UITestCategories.Shell)]
		public void ShellNavigationShouldWorkInMoreTab()
		{
			App.WaitForElementTillPageNavigationSettled("NavigationToPageSixthButton");
			App.Tap("NavigationToPageSixthButton");
			App.WaitForElementTillPageNavigationSettled("NavigateToDetailButton");
			bool navigationSucceeded = false;
			for (int i = 0; i < 3 && !navigationSucceeded; i++)
			{
				try
				{
					App.Tap("NavigateToDetailButton");
					App.WaitForElementTillPageNavigationSettled("NavigateBackButton");
					navigationSucceeded = true;
				}
				catch (Exception)
				{
					TestContext.WriteLine($"Timeout waiting for NavigateBackButton after tapping NavigateToDetailButton");
				}
			}
			Assert.That(navigationSucceeded, Is.True, "Navigation to Detail Page did not succeed after multiple attempts");
			App.Tap("NavigateBackButton");
			App.WaitForElementTillPageNavigationSettled("NavigateToPageTwoButton");
			App.Tap("NavigateToPageTwoButton");
			App.WaitForElementTillPageNavigationSettled("NavigateToPageFiveButton");
			App.Tap("NavigateToPageFiveButton");
			App.WaitForElementTillPageNavigationSettled("More");