Skip to content

Commit

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

* Migrated the Bugzilla44461, 56298,56771,57515, 59172 and 3524

* Addressed the feedbacks

* Added iOS images for Bugzilla56298Test

* Fix flaky test failure of ObservableCollectionChangedListView test case

* Addressed the review comments

* Update Bugzilla56298.cs

---------

Co-authored-by: nivetha-nagalingam <[email protected]>
  • Loading branch information
anandhan-rajagopal and nivetha-nagalingam authored Dec 31, 2024
1 parent 46fb61a commit 07cc973
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ namespace Maui.Controls.Sample.Issues;

public class Issue3524 : TestContentPage
{
const string kText = "Click Me To Increment";

const string kText = "ClickMeToIncrement";
public Command TapCommand { get; set; }
public String Text { get; set; } = kText;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#if ANDROID
#if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST //When clicking Button0 (the first button) incorrectly centers it in the ScrollView instead of maintaining its left alignment.
//Issue Link: https://github.com/dotnet/maui/issues/26760
using NUnit.Framework;
using NUnit.Framework.Legacy;
using UITest.Appium;
Expand All @@ -7,7 +8,6 @@
namespace Microsoft.Maui.TestCases.Tests.Issues
{
[Category(UITestCategories.ScrollView)]
[Category(UITestCategories.Compatibility)]
public class Bugzilla44461UITests : _IssuesUITest
{
public Bugzilla44461UITests(TestDevice device)
Expand All @@ -17,26 +17,23 @@ public Bugzilla44461UITests(TestDevice device)

public override string Issue => "ScrollToPosition.Center works differently on Android and iOS";

// Bugzilla44461 (src\Compatibility\ControlGallery\src\Issues.Shared\Bugzilla44461.cs)
[Test]
[FailsOnIOSWhenRunningOnXamarinUITest("This test is failing, likely due to product issue")]
[FailsOnMacWhenRunningOnXamarinUITest("This test is failing, likely due to product issue")]
[FailsOnWindowsWhenRunningOnXamarinUITest("This test is failing, likely due to product issue")]
public void Bugzilla44461Test()
{
var positions = TapButton(0);
ClassicAssert.AreEqual(positions.initialPosition.X, positions.finalPosition.X);
ClassicAssert.LessOrEqual(positions.finalPosition.X, 1);
App.Screenshot("Button0 is aligned with the left side of the screen");
Assert.That(positions.initialPosition.X, Is.EqualTo(positions.finalPosition.X));
Assert.That(positions.finalPosition.X, Is.LessThanOrEqualTo(1));
}

(System.Drawing.Rectangle initialPosition, System.Drawing.Rectangle finalPosition) TapButton(int position)
{
var buttonId = $"{position}";
App.WaitForElement(buttonId);
var initialPosition = App.FindElement(buttonId).GetRect();
var initialPosition = App.WaitForElement(buttonId).GetRect();
App.Tap(buttonId);
var finalPosition = App.FindElement(buttonId).GetRect();
var finalPosition = App.WaitForElement(buttonId).GetRect();
return (initialPosition, finalPosition);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using NUnit.Framework;
#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST
// ListView.HasUnevenRows Property Changes Not Reflected in UI on Android and Windows Platforms. Issue Link: https://github.com/dotnet/maui/issues/26780
// The CI-generated image on Catalyst doesn't match expectations, seems to be uneven rows aren't working correctly.
// However, the locally generated image appears to function as expected.

using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -10,18 +15,20 @@ public Bugzilla56298(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "[Bug] Changing ListViews HasUnevenRows at runtime on iOS has no effect";
public override string Issue => "Changing ListViews HasUnevenRows at runtime on iOS has no effect";

[Test]
[Category(UITestCategories.ListView)]
[Category(UITestCategories.Compatibility)]
[FailsOnAllPlatformsWhenRunningOnXamarinUITest]
[FailsOnAndroidWhenRunningOnXamarinUITest("This test is failing, likely due to product issue")]
[FailsOnWindowsWhenRunningOnXamarinUITest("This test is failing, likely due to product issue")]
public void Bugzilla56298Test()
{
App.WaitForElement("btnAdd");
App.Tap("btnAdd");
App.WaitForElement("btnToggle");
App.Tap("btnToggle");
App.Screenshot("Verify we see uneven rows");
VerifyScreenshot();
}
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if ANDROID || IOS // TODO: Cannot find the element ZoomContainer on Desktop. Investigate the reason.
#if TEST_FAILS_ON_CATALYST //The test fails on macOS Catalyst because the PinchToZoomIn does not working.
using NUnit.Framework;
using NUnit.Framework.Legacy;
using UITest.Appium;
Expand All @@ -9,6 +9,7 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;
public class Bugzilla57515 : _IssuesUITest
{
const string ZoomContainer = "zoomContainer";
const string ZoomImage = "zoomImg";

public Bugzilla57515(TestDevice testDevice) : base(testDevice)
{
Expand All @@ -18,20 +19,12 @@ public Bugzilla57515(TestDevice testDevice) : base(testDevice)

[Test]
[Category(UITestCategories.Gestures)]
[FailsOnIOSWhenRunningOnXamarinUITest]
public void Bugzilla57515Test()
{
if (App is not AppiumApp app2 || app2 is null || app2.Driver is null)
{
throw new InvalidOperationException("Cannot run test. Missing driver to run quick tap actions.");
}

App.WaitForElement(ZoomContainer);
var zoomScale1 = app2.Driver.FindElement(OpenQA.Selenium.By.XPath("//*[@text='" + "1" + "']"));
ClassicAssert.AreEqual("1", zoomScale1.Text);
App.WaitForElement(ZoomImage);
App.WaitForElement("1");
App.PinchToZoomIn(ZoomContainer);
var elements = app2.Driver.FindElements(OpenQA.Selenium.By.XPath("//*[@text='" + "1" + "']"));
ClassicAssert.AreEqual(0, elements.Count); // The scale should have changed during the zoom
App.WaitForNoElement("1");
}
}
#endif
#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if IOS
using NUnit.Framework;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -18,35 +17,32 @@ public Bugzilla59172(TestDevice testDevice) : base(testDevice)

[Test]
[Category(UITestCategories.Navigation)]
[Category(UITestCategories.Compatibility)]
public async Task Issue59172Test()
public void Issue59172Test()
{
App.WaitForElement("GoForward");
App.Tap("GoForward");
App.WaitForElementTillPageNavigationSettled("GoBackDelayed");
App.Tap("GoBackDelayed");
App.Back();

await Task.Delay(1000);
App.TapBackArrow();

// App should not have crashed
App.WaitForElement("GoForward");
}

[Test]
[Category(UITestCategories.Navigation)]
[Category(UITestCategories.Compatibility)]
public async Task Issue59172RecoveryTest()
public void Issue59172RecoveryTest()
{
App.WaitForElement("GoForward");
App.Tap("GoForward");
App.WaitForElement("GoBackDelayedSafe");
App.Tap("GoBackDelayedSafe");
App.Back();

await Task.Delay(1000);
App.TapBackArrow();

App.Tap("GoForward");

// App should navigate
App.WaitForElement("GoBackDelayedSafe");
}
}
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ public Issue2470(TestDevice testDevice) : base(testDevice)

[Test]
[Category(UITestCategories.ListView)]
public void OnservableCollectionChangeListView()
public void ObservableCollectionChangeListView()
{
App.WaitForElement("Switch");
// Tab 1
App.Tap("Switch");
App.WaitForElement(Results);
App.Tap(Results);

// Tab 2
App.WaitForElement("Entry 0 of 5");
App.WaitForElementTillPageNavigationSettled("Entry 0 of 5");
App.WaitForElement("Entry 1 of 5");
App.WaitForElement("Entry 2 of 5");
App.WaitForElement("Entry 3 of 5");
Expand All @@ -38,21 +39,23 @@ public void OnservableCollectionChangeListView()
App.Tap(Generate);

// Tab 1
App.WaitForElementTillPageNavigationSettled("Switch");
App.Tap("Switch");
App.Tap(Results);

// Tab 2
App.WaitForElement("Entry 0 of 2");
App.WaitForElementTillPageNavigationSettled("Entry 0 of 2");
App.WaitForElement("Entry 1 of 2");


// Tab 1
App.Tap(Generate);
App.WaitForElementTillPageNavigationSettled("Switch");
App.Tap("Switch");
App.Tap(Results);

// Tab 2
App.WaitForElement("Entry 0 of 5");
App.WaitForElementTillPageNavigationSettled("Entry 0 of 5");
App.WaitForElement("Entry 1 of 5");
App.WaitForElement("Entry 2 of 5");
App.WaitForElement("Entry 3 of 5");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue3524 : _IssuesUITest
{
const string kText = "Click Me To Increment";

const string kText = "ClickMeToIncrement";
public Issue3524(TestDevice testDevice) : base(testDevice)
{
}
Expand All @@ -17,12 +16,10 @@ public Issue3524(TestDevice testDevice) : base(testDevice)

[Test]
[Category(UITestCategories.Gestures)]
[FailsOnIOSWhenRunningOnXamarinUITest]
[FailsOnWindowsWhenRunningOnXamarinUITest]
public void SpanGestureCommand()
{
App.WaitForElement(kText);
App.Tap(kText);
App.WaitForElement($"{kText}: 1");
Assert.That(App.WaitForElement(kText).GetText(), Is.EqualTo("ClickMeToIncrement: 1"));
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 07cc973

Please sign in to comment.