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 - 7 #25795

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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 @@ -18,7 +18,7 @@ protected override void Init()
grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Star });
grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
grid.Children.Add(new Label() { Text = "Top Text", BackgroundColor = Colors.Purple });
var bottomLabel = new Label() { Text = "Bottom Text" };
var bottomLabel = new Label() { Text = "Bottom Text", AutomationId="BottomText" };
Grid.SetRow(bottomLabel, 1);
grid.Children.Add(bottomLabel);

Expand All @@ -35,7 +35,7 @@ protected override void Init()
Children.Add((createPage()));
Children.Add(new ContentPage()
{
IconImageSource = "calculator.png",
IconImageSource = "coffee.png",
jsuarezruiz marked this conversation as resolved.
Show resolved Hide resolved
Content = new Button()
{
Text = "Click Me",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void ReloadListViews()
{
ItemTemplate = new DataTemplate(() =>
{
Label nameLabel = new Label() { Text = "Not Grouped Item" };
Label nameLabel = new Label() { Text = "Not Grouped Item", AutomationId = "NotGroupedItem" };
var cell = new ViewCell
{
View = nameLabel,
Expand All @@ -79,11 +79,11 @@ void ReloadListViews()
GroupHeaderTemplate = new DataTemplate(typeof(MyHeaderViewCell)),
ItemTemplate = new DataTemplate(() =>
{
Label nameLabel = new Label() { Text = "Grouped Item" };
Label nameLabel = new Label() { Text = "Grouped Item" , AutomationId = "GroupedItem"};
var cell = new ViewCell
{
View = nameLabel,
};
};
return cell;
}),
};
Expand All @@ -105,6 +105,7 @@ protected override void Init()
new Button()
{
Text = "Click Until Success",
AutomationId = "ClickUntilSuccess",
Command = new Command(() =>
{
if(clickCount == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public MyHeaderViewCell()
Height = 25;
var label = new Label { VerticalOptions = LayoutOptions.Center };
label.SetBinding(Label.TextProperty, nameof(GroupedItem.Name));
label.SetBinding(Label.AutomationIdProperty, nameof(GroupedItem.Name));
View = new StackLayout()
{
Children =
Expand Down Expand Up @@ -80,6 +81,7 @@ void ReloadListViews()
{
Label nameLabel = new Label();
nameLabel.SetBinding(Label.TextProperty, "Text");
nameLabel.SetBinding(Label.AutomationIdProperty, "Text");
var cell = new ViewCell
{
View = nameLabel,
Expand All @@ -100,7 +102,7 @@ protected override void OnAppearing()

protected override void Init()
{
Label label = new Label() { Text = "If you see two group headers and can click on each row without crashing test has passed" };
Label label = new Label() { Text = "If you see two group headers and can click on each row without crashing test has passed", AutomationId = "MessageLabel" };

Content = new StackLayout
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ protected override void Init()
{
Label nameLabel = new Label();
nameLabel.SetBinding(Label.TextProperty, new Binding("Name"));
nameLabel.SetBinding(Label.AutomationIdProperty, new Binding("Name"));
var cell = new ViewCell
{
View = new Frame()
//Frame is obsolete in net9.0, so here changed to border
View = new Border()
{
Content = nameLabel
},
Expand All @@ -41,6 +43,7 @@ protected override void Init()
new Button()
{
Text = _instructions,
AutomationId = "InstructionButton",
Command = new Command(() =>
{
var collection = listView.ItemsSource as ObservableCollection<Item>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if !ANDROID
using NUnit.Framework;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -13,11 +12,10 @@ public Issue2993(TestDevice testDevice) : base(testDevice)

public override string Issue => "[Android] Bottom Tab Bar with a navigation page is hiding content";

// [Test]
// [Category(UITestCategories.Layout)]
// public void BottomContentVisibleWithBottomBarAndNavigationPage()
// {
// App.WaitForElement("Bottom Text");
// }
}
#endif
[Test]
[Category(UITestCategories.Layout)]
public void BottomContentVisibleWithBottomBarAndNavigationPage()
{
App.WaitForElement("BottomText");
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a quick reminder, WaitForElement can find elements by content (text). Something like (no changes):
App.WaitForElement("Bottom Text");
Should work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, WaitForElement can locate elements by text on all platforms except Windows. On Windows, it results in a timeout exception, and in this case, setting the AutomationID is works.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, applied changes to fix it!

}
}
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
#if !ANDROID
using NUnit.Framework;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue3008 : _IssuesUITest
{
const string ClickUntilSuccess = "ClickUntilSuccess";

const string NotGroupedItem = "NotGroupedItem";

const string GroupedItem = "GroupedItem";

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

public override string Issue => "Setting ListView.ItemSource to null doesn't cause it clear out its contents";

// [Test]
// [Category(UITestCategories.ListView)]
// [FailsOnIOS]
// public void EnsureListViewEmptiesOut()
// {
// App.Tap("Click Until Success");
// App.WaitForElement("Not Grouped Item");
// App.WaitForElement("Grouped Item");

// App.Tap("Click Until Success");
// App.WaitForElement("Not Grouped Item");
// App.WaitForElement("Grouped Item");

// App.Tap("Click Until Success");
// App.WaitForNoElement("Not Grouped Item");
// App.WaitForNoElement("Grouped Item");

// App.Tap("Click Until Success");
// App.WaitForElement("Not Grouped Item");
// App.WaitForElement("Grouped Item");

// App.Tap("Click Until Success");
// App.WaitForNoElement("Not Grouped Item");
// App.WaitForNoElement("Grouped Item");

// App.Tap("Click Until Success");
// App.WaitForElement("Not Grouped Item");
// App.WaitForElement("Grouped Item");

// App.Tap("Click Until Success");
// App.WaitForNoElement("Not Grouped Item");
// App.WaitForNoElement("Grouped Item");
// }
}
#endif
[Test]
[Category(UITestCategories.ListView)]
public void EnsureListViewEmptiesOut()
{
App.WaitForElement(ClickUntilSuccess);
App.Tap(ClickUntilSuccess);
App.WaitForElement(NotGroupedItem);
App.WaitForElement(GroupedItem);

App.Tap(ClickUntilSuccess);
App.WaitForElement(NotGroupedItem);
App.WaitForElement(GroupedItem);

App.Tap(ClickUntilSuccess);
App.WaitForNoElement(NotGroupedItem);
App.WaitForNoElement(GroupedItem);

App.Tap(ClickUntilSuccess);
App.WaitForElement(NotGroupedItem);
App.WaitForElement(GroupedItem);

App.Tap(ClickUntilSuccess);
App.WaitForNoElement(NotGroupedItem);
App.WaitForNoElement(GroupedItem);

App.Tap(ClickUntilSuccess);
App.WaitForElement(NotGroupedItem);
App.WaitForElement(GroupedItem);

App.Tap(ClickUntilSuccess);
App.WaitForNoElement(NotGroupedItem);
App.WaitForNoElement(GroupedItem);
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
#if MACCATALYST
using NUnit.Framework;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue3012 : _IssuesUITest
{
const string DumbyEntry = "DumbyEntry";
const string FocusTargetEntry = "FocusTargetEntry";

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

public override string Issue => "[macOS] Entry focus / unfocus behavior";

// [Test]
// [Category(UITestCategories.Entry)]
// public void Issue3012Test()
// {
// App.WaitForElement(q => q.Marked("DumbyEntry"));
// App.Tap(q => q.Marked("DumbyEntry"));

// App.WaitForElement(q => q.Marked("FocusTargetEntry"));
// App.Tap(q => q.Marked("FocusTargetEntry"));
// Assert.AreEqual(0, _unfocusedCount, "Unfocused should not have fired");

// App.Tap(q => q.Marked("DumbyEntry"));
// Assert.AreEqual(1, _unfocusedCount, "Unfocused should have been fired once");
// }
}
#endif
[Test]
[Category(UITestCategories.Entry)]
public void Issue3012Test()
{
App.WaitForElement(DumbyEntry);
App.Tap(DumbyEntry);
App.Tap(FocusTargetEntry);
Assert.That(App.FindElement("UnfocusedCountLabel").GetText(), Is.EqualTo($"Unfocused count: {0}"));
App.Tap(DumbyEntry);
Assert.That(App.FindElement("UnfocusedCountLabel").GetText(), Is.EqualTo($"Unfocused count: {1}"));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NUnit.Framework;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -12,16 +12,13 @@ public Issue3019(TestDevice testDevice) : base(testDevice)

public override string Issue => "Grouped ListView Header empty for adding items";

// [Test]
// [Category(UITestCategories.ListView)]
// [FailsOnIOS]
// public void MakeSureListGroupShowsUpAndItemsAreClickable()
// {
// App.WaitForElement("Group 1");

// App.Tap(x => x.Marked("Grouped Item: 0"));
// App.Tap(x => x.Marked("Grouped Item: 1"));
// App.Tap(x => x.Marked("Grouped Item: 1 Clicked"));

// }
[Test]
[Category(UITestCategories.ListView)]
public void MakeSureListGroupShowsUpAndItemsAreClickable()
{
App.Tap("Grouped Item: 0");
Assert.That(App.WaitForElement("MessageLabel").GetText(), Is.EqualTo("Grouped Item: 0 Clicked"));
App.Tap("Grouped Item: 1");
Assert.That(App.WaitForElement("MessageLabel").GetText(), Is.EqualTo("Grouped Item: 1 Clicked"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ public Issue3053(TestDevice testDevice) : base(testDevice)

public override string Issue => "Moving items around on an Observable Collection causes the last item to disappear";

// [Test]
// [Category(UITestCategories.ListView)]
// [FailsOnIOS]
// [FailsOnAndroid]
// public void MovingItemInObservableCollectionBreaksListView()
// {
// App.WaitForElement(_instructions);
// App.Tap(_instructions);
// App.WaitForElement("Item 2");
// }
[Test]
[Category(UITestCategories.ListView)]
public void MovingItemInObservableCollectionBreaksListView()
{
App.WaitForElement("InstructionButton");
App.Tap("InstructionButton");
App.WaitForElement("Item 2");
}
}
Loading