Skip to content

Commit

Permalink
[Testing] Enabling ported UITests from Xamarin.UITests to Appium - 5 (d…
Browse files Browse the repository at this point in the history
…otnet#25772)

* enabled few UI tests from XamarinUITests into Appium

* Included the extension method for TapBackArrow

* added ifdefines for failed case on windows and added image for failed case in mac

* Update Issue889.cs
  • Loading branch information
anandhan-rajagopal authored Dec 2, 2024
1 parent 1a88b34 commit b1f3340
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 49 deletions.
16 changes: 14 additions & 2 deletions src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue3318.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ protected override void Init()
var stackLayout = new StackLayout();

var list = Enumerable.Range(0, 40).Select(c => $"Item {c}").ToArray();
var listview = new ListView { ItemsSource = list };
var listview = new ListView {
ItemsSource = list,
ItemTemplate = new DataTemplate(() =>
{
var viewCell = new ViewCell();
var itemTemplateLabel = new Label() { HeightRequest = 30};
itemTemplateLabel.SetBinding(Label.TextProperty, new Binding("."));
itemTemplateLabel.SetBinding(Label.AutomationIdProperty, new Binding("."));
viewCell.View = itemTemplateLabel;
return viewCell;
})

};

var swShouldAnimate = new Switch();
var lblShouldAnimate = new Label { Text = "Should Animate?" };
Expand All @@ -33,7 +45,7 @@ protected override void Init()
listview.ScrollTo(list[19], ScrollToPosition.Start, swShouldAnimate.IsToggled);
};

var btnEnd = new Button { Text = "End" };
var btnEnd = new Button { Text = "End", AutomationId = "End" };
btnEnd.Clicked += (s, e) =>
{
listview.ScrollTo(list[19], ScrollToPosition.End, swShouldAnimate.IsToggled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public NestedNavTabPageRootView(string pageTitle)
{
new Button {
Text = "Push new page",
AutomationId = "PushPage",
Command = new Command (() => Navigation.PushAsync (new NestedNavTabPageOneLevel ()))
}
}
Expand All @@ -79,6 +80,7 @@ public NestedNavTabPageRootView(string pageTitle)
{
new Button {
Text = "Push new page",
AutomationId = "SecondTabPageButton",
Command = new Command (() => Navigation.PushAsync (new NestedNavTabPageOneLevel ()))
}
}
Expand All @@ -103,7 +105,8 @@ public NestedNavTabPageOneLevel()
Children = {
new Label {
TextColor = Colors.Red,
Text = "I have been pushed"
Text = "I have been pushed",
AutomationId = "PushedPageLabel"
}
}
};
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
#if IOS
#if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS
// In Windows the app gets crashes randomly while executing the test.
// In Catalyst the animation happens while tab changes which cause additional delays. Tried by adding timespan still getting OpenQA.Selenium.InvalidSelectorException on line no 25.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;
Expand All @@ -19,12 +20,12 @@ public Issue12642(TestDevice testDevice) : base(testDevice)
[Category(UITestCategories.Compatibility)]
public void ClickingQuicklyBetweenTopTabsBreaksContent()
{
App.WaitForElement("AutomatedRun");
App.Tap("AutomatedRun");
App.WaitForElement("Success");
App.Tap("AutomatedRun");
App.WaitForElement("Success");
App.WaitForElement("Success");
}
}
}
#endif
*/
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ public Issue3318(TestDevice testDevice) : base(testDevice)

public override string Issue => "[MAC] ScrollTo method is not working in Xamarin.Forms for mac platform";

// [Test]
// [Category(UITestCategories.ListView)]
// [FailsOnIOS]
// public void Issue3318Test()
// {
// App.WaitForElement(q => q.Marked("End"));
// App.Tap(q => q.Marked("End"));
// App.WaitForElement(q => q.Marked("Item 19"));
// App.Back();
// }
[Test]
[Category(UITestCategories.ListView)]
public void Issue3318Test()
{
App.WaitForElement("End");
App.Tap("End");
App.WaitForElement("Item 19");
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
using NUnit.Framework;
#if ANDROID
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue7311 : _IssuesUITest
{
const string FirstPickerItem = "Uno";

const string PickerId = "CaptainPickard";

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

public override string Issue => "[Bug] [Android] Error back hardware button with Picker";

//[Test]
//[Category(UITestCategories.Picker)]
//public void OpeningPickerPressingBackButtonTwiceShouldNotOpenPickerAgain()
//{
// App.WaitForElement(PickerId);
// App.Tap(PickerId);

// App.WaitForElement(FirstPickerItem);
[Test]
[Category(UITestCategories.Picker)]
public void OpeningPickerPressingBackButtonTwiceShouldNotOpenPickerAgain()
{
App.WaitForElement(PickerId);
App.Tap(PickerId);

// App.Back();
App.WaitForElement(FirstPickerItem);

// App.WaitForNoElement(FirstPickerItem);
App.Back();

// App.Back();
App.WaitForNoElement(FirstPickerItem);

// App.WaitForNoElement(FirstPickerItem, "Picker is again visible after second back button press", TimeSpan.FromSeconds(10));
//The Below actions are not possible due to the current implementation of the Host app, the issue page has designated the MainPage of the Current Application.
//App.Back();
//App.WaitForNoElement(FirstPickerItem, "Picker is again visible after second back button press", TimeSpan.FromSeconds(10));

// App.Screenshot("Back at the previous page, not showing the picker again");
//}
}
App.Screenshot("Back at the previous page, not showing the picker again");
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
using NUnit.Framework;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue889 : _IssuesUITest
{

#if ANDROID
const string Tab2Title = "TAB 2 TITLE";
#else
const string Tab2Title = "Tab 2 Title";
#endif
public Issue889(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Assigning to FlyoutPage.Detail after construction doesn't work";

//[Test]
//[Category(UITestCategories.FlyoutPage)]
//[Description("Reproduce app crash - Issue #983")]
//public void Issue899TestsAppCrashWhenSwitchingTabs()
//{
// App.Tap(q => q.Marked("Push new page"));
// App.WaitForElement(q => q.Marked("I have been pushed"));
// App.Screenshot("Push page");
// App.Back();
// App.Screenshot("Navigate back");
[Test]
[Category(UITestCategories.FlyoutPage)]
public void Issue899TestsAppCrashWhenSwitchingTabs()
{
App.WaitForElement("PushPage");
App.Tap("PushPage");
App.WaitForElement("PushedPageLabel");

#if IOS || MACCATALYST
App.Tap(AppiumQuery.ByName("Initial Page"));
#else
App.TapBackArrow();
#endif

// App.Tap(q => q.Marked("Tab 2 Title"));
// App.Screenshot("Go to second tab");
//}
}
App.Tap(Tab2Title);
App.WaitForElement("SecondTabPageButton");
}
}

0 comments on commit b1f3340

Please sign in to comment.