From 6b2617ff8c7ce3fce310150cc3f93feb621e2d8b Mon Sep 17 00:00:00 2001 From: eriklimakc Date: Wed, 28 Aug 2024 17:04:53 +0100 Subject: [PATCH] test: Fix When_Commerce_Backbutton for android --- .../TestHarness.UITest/AppExtensions.cs | 2 +- .../Apps/Commerce/Given_Apps_Commerce.cs | 19 +++++------ .../Extensions/AppExtensions.cs | 2 +- .../Apps/Commerce/CommerceDealsPage.xaml | 34 +++++++------------ 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/testing/TestHarness/TestHarness.UITest/AppExtensions.cs b/testing/TestHarness/TestHarness.UITest/AppExtensions.cs index aa4e2a063d..93701d39da 100644 --- a/testing/TestHarness/TestHarness.UITest/AppExtensions.cs +++ b/testing/TestHarness/TestHarness.UITest/AppExtensions.cs @@ -14,7 +14,7 @@ public static async Task TapAndWait(this IApp app, string elementToTap, string e await Task.Delay(UIWaitTimeInMilliseconds); } - public static async Task SelectListViewIndexAndWait(this IApp app, string listName, string indexToSelect, string elementToWaitFor) + public static async Task SelectElementIndexAndWait(this IApp app, string listName, string indexToSelect, string elementToWaitFor) { app.WaitElement(listName); await Task.Delay(UIWaitTimeInMilliseconds); diff --git a/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/Commerce/Given_Apps_Commerce.cs b/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/Commerce/Given_Apps_Commerce.cs index df1874e32f..d1a726180b 100644 --- a/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/Commerce/Given_Apps_Commerce.cs +++ b/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/Commerce/Given_Apps_Commerce.cs @@ -23,16 +23,17 @@ public async Task When_Commerce_Backbutton() await App.TapAndWait("DealsTabBarItem", "DealsNavigationBar"); // Select a deal - await App.TapAndWait("DealsPage_DealsTabBarItem", "DealsListView"); + await App.SelectElementIndexAndWait("DealsTabBar", "0", "DealsListView"); - await App.SelectListViewIndexAndWait("DealsListView", "1", "ProductDetailsNavigationBar"); + await App.SelectElementIndexAndWait("DealsListView", "1", "ProductDetailsNavigationBar"); // Go back to list of deals - await App.TapAndWait("DetailsBackButton", "DealsListView"); + App.WaitThenTap("DetailsBackButton"); + await App.SelectElementIndexAndWait("DealsTabBar", "0", "DealsListView"); // Select another deal - await App.SelectListViewIndexAndWait("DealsListView", "2", "ProductDetailsNavigationBar"); + await App.SelectElementIndexAndWait("DealsListView", "2", "ProductDetailsNavigationBar"); // Go back to list of deals await App.TapAndWait("DetailsBackButton", "DealsListView"); @@ -66,14 +67,14 @@ public async Task When_Commerce_Responsive() // Select a deal await App.TapAndWait("DealsTabBarItem", "DealsListView"); - await App.SelectListViewIndexAndWait("DealsListView", "1", "ProductDetailsNavigationBar"); + await App.SelectElementIndexAndWait("DealsListView", "1", "ProductDetailsNavigationBar"); await App.TapAndWait("DetailsBackButton", "DealsNavigationBar"); // Select a product await App.TapAndWait("ProductsTabBarItem", "ProductsListView"); - await App.SelectListViewIndexAndWait("ProductsListView", "2", "ProductDetailsNavigationBar"); + await App.SelectElementIndexAndWait("ProductsListView", "2", "ProductDetailsNavigationBar"); await App.TapAndWait("DetailsBackButton", "ProductsNavigationBar"); @@ -106,14 +107,14 @@ public async Task When_Commerce_Responsive() // Select a deal await App.TapAndWait("DealsNavigationViewItem", "DealsListView"); - await App.SelectListViewIndexAndWait("DealsListView", "2", "ProductDetailsNavigationBar"); + await App.SelectElementIndexAndWait("DealsListView", "2", "ProductDetailsNavigationBar"); App.WaitElement("DealsNavigationBar"); // Select a product await App.TapAndWait("ProductsNavigationViewItem", "ProductsListView"); - await App.SelectListViewIndexAndWait("ProductsListView", "1", "ProductDetailsNavigationBar"); + await App.SelectElementIndexAndWait("ProductsListView", "1", "ProductDetailsNavigationBar"); App.WaitElement("ProductsNavigationBar"); // Log out @@ -123,7 +124,6 @@ public async Task When_Commerce_Responsive() } - [Test] public async Task When_ViewModelInstance() { @@ -177,7 +177,6 @@ public async Task When_ViewModelInstance() } - [Test] public async Task When_BackgroundThread() { diff --git a/testing/TestHarness/TestHarness.UITest/Extensions/AppExtensions.cs b/testing/TestHarness/TestHarness.UITest/Extensions/AppExtensions.cs index b110cf3812..b76a2e53d4 100644 --- a/testing/TestHarness/TestHarness.UITest/Extensions/AppExtensions.cs +++ b/testing/TestHarness/TestHarness.UITest/Extensions/AppExtensions.cs @@ -48,7 +48,7 @@ public static Func WaitThenTap(this IApp app, string marke public static IAppResult[] WaitElement(this IApp app, string marked, string timeoutMessage = "Timed out waiting for element '{0}'...", TimeSpan? timeout = null, TimeSpan? retryFrequency = null, TimeSpan? postTimeout = null) { Console.WriteLine($"Waiting for '{marked}'"); - return app.WaitForElement(q => q.All().Marked(marked), string.Format(timeoutMessage,marked), timeout, retryFrequency, postTimeout); + return app.WaitForElement(q => q.All().Marked(marked), string.Format(timeoutMessage, marked), timeout, retryFrequency, postTimeout); } public static QueryEx MarkedAnywhere(this IApp app, string marked) diff --git a/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Commerce/CommerceDealsPage.xaml b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Commerce/CommerceDealsPage.xaml index 87fc1cdabf..90644cb22a 100644 --- a/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Commerce/CommerceDealsPage.xaml +++ b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Commerce/CommerceDealsPage.xaml @@ -18,24 +18,18 @@ - + - - - - - + + + + + @@ -56,18 +50,15 @@ - + - - + + @@ -86,7 +77,9 @@ Content="Product Details" Click="{x:Bind ViewModel.ShowProduct}" /> - + - +