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] Enabling ported UITests from Xamarin.UITests to Appium - 20 #26142

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Issue8279 : TestContentPage
const string ScrollWithItemWithGroup = "ScrollWithItemWithGroup";
const string ScrollWithNoItemNoGroup = "ScrollWithNoItemNoGroup";
const string ScrollWithNoItemEmptyGroup = "ScrollWithNoItemEmptyGroup";
const string Reset = "Reset";
const string ResetButton = "Reset";

protected override void Init()
{
Expand Down Expand Up @@ -97,7 +97,7 @@ public Issue8279()
var resetButton = new Button()
{
Text = "Reset",
AutomationId = Reset,
AutomationId = ResetButton,
Command = new Command(() => List.ScrollTo(null, firstGroup, ScrollToPosition.Center, true))
};

Expand All @@ -111,13 +111,13 @@ public Issue8279()
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore CS0618 // Type or member is obsolete

stackLayout.AddLogicalChild(resetButton);
stackLayout.AddLogicalChild(button1);
stackLayout.AddLogicalChild(button2);
stackLayout.AddLogicalChild(button3);
stackLayout.AddLogicalChild(button4);
stackLayout.AddLogicalChild(button5);
stackLayout.AddLogicalChild(List);
stackLayout.Children.Add(resetButton);
stackLayout.Children.Add(button1);
stackLayout.Children.Add(button2);
stackLayout.Children.Add(button3);
stackLayout.Children.Add(button4);
stackLayout.Children.Add(button5);
stackLayout.Children.Add(List);

Content = stackLayout;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 8461, "[Bug] [iOS] [Shell] \"Nav Stack consistency error\"", PlatformAffected.iOS)]
[Issue(IssueTracker.Github, 8461, "[Bug] [iOS] [Shell] Nav Stack consistency error", PlatformAffected.iOS)]
public class Issue8461 : TestShell
{
const string ButtonId = "PageButtonId";
Expand Down Expand Up @@ -28,6 +28,7 @@ protected override void Init()
{
new Label()
{
AutomationId = "InstructionsLabel",
Text = "1. Swipe left to dismiss this page, but cancel the gesture before it completes"
},
new Label()
Expand Down Expand Up @@ -55,7 +56,7 @@ protected override void Init()
};

// Use this BoxView to anchor our swipe to left of the screen
grid.AddLogicalChild(new BoxView()
grid.Children.Add(new BoxView()
{
AutomationId = LayoutId,
HorizontalOptions = LayoutOptions.FillAndExpand,
Expand All @@ -66,7 +67,7 @@ protected override void Init()
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore CS0618 // Type or member is obsolete
grid.AddLogicalChild(instructions);
grid.Children.Add(instructions);

page2.Content = grid;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/TestCases.HostApp/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static MauiApp CreateMauiApp()
{
var appBuilder = MauiApp.CreateBuilder();

#if IOS || ANDROID
#if IOS || ANDROID || MACCATALYST
appBuilder.UseMauiMaps();
#endif
appBuilder.UseMauiApp<App>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
/*using NUnit.Framework;
#if TEST_FAILS_ON_WINDOWS //Maps control is not supported on Windows platform.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Bugzilla26171 : _IssuesUITest
{
public Bugzilla26171(TestDevice testDevice) : base(testDevice)
{
}
public Bugzilla26171(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Microsoft.Maui.Controls.Maps is not updating VisibleRegion property when layout is changed";
public override string Issue => "Microsoft.Maui.Controls.Maps is not updating VisibleRegion property when layout is changed";

[Test]
[Category(UITestCategories.Maps)]
public void Bugzilla26171Test()
{
App.WaitForElement("lblValue");
}
}*/
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_WINDOWS // Text is not rendered on windows. Issue - https://github.com/dotnet/maui/issues/22731
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -12,24 +13,23 @@ public Issue2927(TestDevice testDevice) : base(testDevice)

public override string Issue => "ListView item tapped not firing multiple times";

// [Test]
// [Category(UITestCategories.ListView)]
// [FailsOnIOS]
// public void Issue2927Test()
// {
// App.Screenshot("I am at Issue 2927");
// App.WaitForElement(q => q.Marked("Cell1 0"));
// App.Tap(q => q.Marked("Cell1 0"));
// App.WaitForElement(q => q.Marked("Cell1 1"));
// App.Screenshot("Tapped Once");
// App.Tap(q => q.Marked("Cell1 1"));
// App.WaitForElement(q => q.Marked("Cell1 2"));
// App.Screenshot("Tapped Twice");
// App.Tap(q => q.Marked("Cell3 0"));
// App.WaitForElement(q => q.Marked("Cell3 1"));
// App.Screenshot("Click other cell");
// App.Tap(q => q.Marked("Cell1 2"));
// App.WaitForElement(q => q.Marked("Cell1 3"));
// App.Screenshot("Click first cell again");
// }
}
[Test]
[Category(UITestCategories.ListView)]
public void Issue2927Test()
{

App.WaitForElement("Cell1 0");
App.Tap("Cell1 0");
App.WaitForElement("Cell1 1");

App.Tap("Cell1 1");
App.WaitForElement("Cell1 2");

App.Tap("Cell3 0");
App.WaitForElement("Cell3 1");

App.Tap("Cell1 2");
App.WaitForElement("Cell1 3");
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -10,61 +10,66 @@ public class Issue8279 : _IssuesUITest
public Issue8279(TestDevice testDevice) : base(testDevice)
{
}

const string ScrollWithNoItemButGroup = "ScrollWithNoItemButGroup";
const string ScrollWithItemButNoGroup = "ScrollWithItemButNoGroup";
const string ScrollWithItemWithGroup = "ScrollWithItemWithGroup";
const string ScrollWithNoItemNoGroup = "ScrollWithNoItemNoGroup";
const string ScrollWithNoItemEmptyGroup = "ScrollWithNoItemEmptyGroup";
const string ResetButton = "Reset";
public override string Issue => "[Feature requested] ListView do not ScrollTo a group when there is no child of this group";

//[Test]
//public void ScrollWithNoItemButGroupTest()
//{
// App.WaitForElement(Reset);
// App.Tap(Reset);
// App.WaitForElement(ScrollWithNoItemButGroup);
// App.Tap(ScrollWithNoItemButGroup);
// // This will fail if the list didn't scroll. If it did scroll, it will succeed
// App.WaitForElement(q => q.Marked("Header 3"), timeout: TimeSpan.FromSeconds(2));
//}
[Test]
public void AScrollWithNoItemButGroupTest()
{
App.WaitForElement(ResetButton);
App.Tap(ResetButton);
App.WaitForElement(ScrollWithNoItemButGroup);
App.Tap(ScrollWithNoItemButGroup);
// This will fail if the list didn't scroll. If it did scroll, it will succeed
App.WaitForElement("Header 3");
}

//[Test]
//public void ScrollWithItemButNoGroupTest()
//{
// App.WaitForElement(Reset);
// App.Tap(Reset);
// App.WaitForElement(ScrollWithItemButNoGroup);
// App.Tap(ScrollWithItemButNoGroup);
// // This will fail if the list didn't scroll. If it did scroll, it will succeed
// App.WaitForElement(q => q.Marked("title 1"), timeout: TimeSpan.FromSeconds(2));
//}
[Test]
public void BScrollWithItemButNoGroupTest()
{
App.WaitForElement(ResetButton);
App.Tap(ResetButton);
App.WaitForElement(ScrollWithItemButNoGroup);
App.Tap(ScrollWithItemButNoGroup);
// This will fail if the list didn't scroll. If it did scroll, it will succeed
App.WaitForElement("title 1");
}

//[Test]
//public void ScrollWithItemWithGroupTest()
//{
// App.WaitForElement(Reset);
// App.Tap(Reset);
// App.WaitForElement(ScrollWithItemWithGroup);
// App.Tap(ScrollWithItemWithGroup);
// // This will fail if the list didn't scroll. If it did scroll, it will succeed
// App.WaitForElement(q => q.Marked("Header 3"), timeout: TimeSpan.FromSeconds(2));
//}
[Test]
public void CScrollWithItemWithGroupTest()
{
App.WaitForElement(ResetButton);
App.Tap(ResetButton);
App.WaitForElement(ScrollWithItemWithGroup);
App.Tap(ScrollWithItemWithGroup);
// This will fail if the list didn't scroll. If it did scroll, it will succeed
App.WaitForElement("Header 3");
}

//[Test]
//public void ScrollWithNoItemNoGroupTest()
//{
// App.WaitForElement(Reset);
// App.Tap(Reset);
// App.WaitForElement(ScrollWithNoItemNoGroup);
// App.Tap(ScrollWithNoItemNoGroup);
// // This will pass if the list didn't scroll and remain on the same state
// App.WaitForElement(q => q.Marked("Header 1"), timeout: TimeSpan.FromSeconds(2));
//}
[Test]
public void DScrollWithNoItemNoGroupTest()
{
App.WaitForElement(ResetButton);
App.Tap(ResetButton);
App.WaitForElement(ScrollWithNoItemNoGroup);
App.Tap(ScrollWithNoItemNoGroup);
// This will pass if the list didn't scroll and remain on the same state
App.WaitForElement("Header 1");
}

//[Test]
//public void ScrollWithNoItemEmptyGroupTest()
//{
// App.WaitForElement(Reset);
// App.Tap(Reset);
// App.WaitForElement(ScrollWithNoItemEmptyGroup);
// App.Tap(ScrollWithNoItemEmptyGroup);
// // This will fail if the list didn't scroll. If it did scroll, it will succeed
// App.WaitForElement(q => q.Marked("Header 2"), timeout: TimeSpan.FromSeconds(2));
//}
[Test]
public void EScrollWithNoItemEmptyGroupTest()
{
App.WaitForElement(ResetButton);
App.Tap(ResetButton);
App.WaitForElement(ScrollWithNoItemEmptyGroup);
App.Tap(ScrollWithNoItemEmptyGroup);
// This will fail if the list didn't scroll. If it did scroll, it will succeed
App.WaitForElement("Header 2");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_CATALYST // TouchAndHold not supported on Mac, Also using LongPress is not applicable on this case, while LongPress does not open the context menu for Entry/Editor control.
using NUnit.Framework;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you try to use App.RightClick?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz , When manually testing the sample, right-clicking opens the context menus. However, during automation, while the App.RightClick function executes, the context menu does not appear. Nonetheless, the test passes because the copy, paste, and edit buttons are accessible in the macOS app menu bar. I have attached video for reference, can you please take a look and share your suggestions.
Mannual Test:

image

Automation Test:

Screen.Recording.2024-11-27.at.4.30.10.PM.mov

using UITest.Appium;
using UITest.Core;

Expand All @@ -12,31 +13,34 @@ public Issue8291(TestDevice testDevice) : base(testDevice)

public override string Issue => "[Android] Editor - Text selection menu does not appear when selecting text on an editor placed within a ScrollView";

//[Test]
//[Category(UITestCategories.Editor)]
//[FailsOnAndroidWhenRunningOnXamarinUITest]
//public void ContextMenuShowsUpWhenPressAndHoldTextOnEditorAndEntryField()
//{
// App.TouchAndHold("PressEditor");
// TestForPopup();
// App.Tap("PressEntry");
// App.TouchAndHold("PressEntry");
// TestForPopup();
//}

//void TestForPopup()
//{
// var result = App.QueryUntilPresent(() =>
// {
// return App.Query("Paste")
// .Union(App.Query("Share"))
// .Union(App.Query("Copy"))
// .Union(App.Query("Cut"))
// .Union(App.Query("Select All"))
// .ToArray();
// });

// Assert.IsNotNull(result);
// Assert.IsTrue(result.Length > 0);
//}
}
[Test]
[Category(UITestCategories.Editor)]
public void ContextMenuShowsUpWhenPressAndHoldTextOnEditorAndEntryField()
{
App.WaitForElement("PressEditor");
App.TouchAndHold("PressEditor");

TestForPopup();
App.Tap("PressEntry");

App.TouchAndHold("PressEditor");
TestForPopup();
}

void TestForPopup()
{
var result = App.QueryUntilPresent(() =>
{
return "Paste"
.Union("Share")
.Union("Copy")
.Union("Cut")
.Union("Select All")
.ToArray();
});

Assert.That(result, Is.Not.Null);
Assert.That(result.Length, Is.GreaterThan(0));
}
}
#endif
Loading
Loading