From c5e52dfdfa98031a2d276ac72d3c48c4e516da6a Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Thu, 9 Jan 2020 13:02:49 -0700 Subject: [PATCH] - one more TapOverflowMenuButton --- .../Issue2809.cs | 2 +- .../Tests/ToolbarItemTests.cs | 20 ++---------------- .../Utilities/AppExtensions.cs | 21 +++++++++++++++++++ 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2809.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2809.cs index c927c1c5a10..5888c3b0092 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2809.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2809.cs @@ -45,7 +45,7 @@ void ShouldShowMenu () { #if __ANDROID__ //show secondary menu - RunningApp.Tap (c => c.Class ("OverflowMenuButton")); + RunningApp.TapOverflowMenuButton(); #elif __WINDOWS__ RunningApp.Tap ("MoreButton"); #endif diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/ToolbarItemTests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/ToolbarItemTests.cs index 2d2681f855e..83d5008b4fe 100644 --- a/Xamarin.Forms.Core.UITests.Shared/Tests/ToolbarItemTests.cs +++ b/Xamarin.Forms.Core.UITests.Shared/Tests/ToolbarItemTests.cs @@ -4,7 +4,7 @@ using NUnit.Framework; using Xamarin.Forms.Controls; using Xamarin.Forms.CustomAttributes; - +using Xamarin.UITest; using Xamarin.UITest.Queries; namespace Xamarin.Forms.Core.UITests @@ -31,23 +31,7 @@ bool isSecondaryMenuOpen() #endif void ShouldShowMenu() { -#if __ANDROID__ - // show secondary menu - // When running these tests as release/d8/r8/AndroidX the runner was having trouble locating "OverflowMenuButton" - // so we search through the ActionMenu for the button - var menuElements = App.WaitForElement(c => c.Class("ActionMenuView").Descendant()); - var menuElement = menuElements.Where(x => x.Class.Contains("OverflowMenuButton")).FirstOrDefault(); - - if (menuElement != null) - { - App.Tap(c => c.Class(menuElement.Class)); - } - else - { - App.WaitForElement(c => c.Class("OverflowMenuButton")); - App.Tap(c => c.Class("OverflowMenuButton")); - } -#endif + App.TapOverflowMenuButton(); } void ShouldHideMenu() diff --git a/Xamarin.Forms.Core.UITests.Shared/Utilities/AppExtensions.cs b/Xamarin.Forms.Core.UITests.Shared/Utilities/AppExtensions.cs index 79c8a429071..f54a3c4bc76 100644 --- a/Xamarin.Forms.Core.UITests.Shared/Utilities/AppExtensions.cs +++ b/Xamarin.Forms.Core.UITests.Shared/Utilities/AppExtensions.cs @@ -43,6 +43,27 @@ public static bool IsApiHigherThan(this IApp app, int apiLevel, string apiLabelI return true; } + public static void TapOverflowMenuButton(this IApp app) + { +#if __ANDROID__ + // show secondary menu + // When running these tests as release/d8/r8/AndroidX the runner was having trouble locating "OverflowMenuButton" + // so we search through the ActionMenu for the button + var menuElements = app.WaitForElement(c => c.Class("ActionMenuView").Descendant()); + var menuElement = menuElements.Where(x => x.Class.Contains("OverflowMenuButton")).FirstOrDefault(); + + if (menuElement != null) + { + app.Tap(c => c.Class(menuElement.Class)); + } + else + { + app.WaitForElement(c => c.Class("OverflowMenuButton")); + app.Tap(c => c.Class("OverflowMenuButton")); + } +#endif + } + public static bool IsTablet(this IApp app) { #if __IOS__