Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
- one more TapOverflowMenuButton
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen committed Jan 9, 2020
1 parent cc74a5b commit c5e52df
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 2 additions & 18 deletions Xamarin.Forms.Core.UITests.Shared/Tests/ToolbarItemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
21 changes: 21 additions & 0 deletions Xamarin.Forms.Core.UITests.Shared/Utilities/AppExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down

0 comments on commit c5e52df

Please sign in to comment.