Skip to content

Commit e145e91

Browse files
jsuarezruizPureWeen
authored andcommitted
Fix TapCoordinates method in Catalyst (#29775)
1 parent 852458b commit e145e91

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue12685.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ public void ShapesPathReceiveGestureRecognizers()
2121
{
2222
var testLabel = App.WaitForFirstElement(StatusLabelId);
2323
Assert.That(testLabel.ReadText(), Is.EqualTo(ResetStatus));
24-
var labelRect = App.WaitForFirstElement(StatusLabelId).GetRect(); // Path element not able get via automationid so getting the rect of the label calculated points to tap on the path
25-
#if MACCATALYST // TapCoordinates is not working on MacCatalyst Issue: https://github.com/dotnet/maui/issues/19754
26-
App.ClickCoordinates(labelRect.X + 3, labelRect.Y - 10);
27-
#else
24+
var labelRect = App.WaitForFirstElement(StatusLabelId).GetRect(); // Path element not able get via AutomationId so getting the rect of the label calculated points to tap on the path
2825
App.TapCoordinates(labelRect.X + 3, labelRect.Y - 10);
29-
#endif
3026
App.WaitForElement(StatusLabelId);
3127
Assert.That(testLabel.ReadText(), Is.EqualTo(ClickedStatus));
3228
}

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue2894.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ public void VariousSpanGesturePermutation()
4444

4545
void PerformGestureAction(float x, float y)
4646
{
47-
#if MACCATALYST // TapCoordinates is not working on MacCatalyst Issue: https://github.com/dotnet/maui/issues/19754
48-
App.ClickCoordinates(x, y);
49-
#else
5047
App.TapCoordinates(x, y);
51-
#endif
5248
}
5349

5450
void PerformGestureActionForFirstSpan(Rectangle target)

src/TestUtils/src/UITest.Appium/HelperExtensions.cs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ public static class HelperExtensions
1616
/// <summary>
1717
/// For desktop, this will perform a mouse click on the target element.
1818
/// For mobile, this will tap the element.
19-
/// This API works for all platforms whereas TapCoordinates currently doesn't work on Catalyst
20-
/// https://github.com/dotnet/maui/issues/19754
2119
/// </summary>
2220
/// <param name="app">Represents the main gateway to interact with an app.</param>
2321
/// <param name="element">Target Element.</param>
@@ -29,8 +27,6 @@ public static void Tap(this IApp app, string element)
2927
/// <summary>
3028
/// For desktop, this will perform a mouse click on the target element.
3129
/// For mobile, this will tap the element.
32-
/// This API works for all platforms whereas TapCoordinates currently doesn't work on Catalyst
33-
/// https://github.com/dotnet/maui/issues/19754
3430
/// </summary>
3531
/// <param name="app">Represents the main gateway to interact with an app.</param>
3632
/// <param name="query">Represents the query that identify an element by parameters such as type, text it contains or identifier.</param>
@@ -308,8 +304,6 @@ public static void Click(this IUIElement element)
308304
/// <summary>
309305
/// For desktop, this will perform a mouse click on the target element.
310306
/// For mobile, this will tap the element.
311-
/// This API works for all platforms whereas TapCoordinates currently doesn't work on Catalyst
312-
/// https://github.com/dotnet/maui/issues/19754
313307
/// </summary>
314308
/// <param name="element">Target Element.</param>
315309
public static void Tap(this IUIElement element)
@@ -409,11 +403,18 @@ internal static void DoubleTap(this IApp app, IUIElement? element)
409403
/// <param name="y">The y coordinate to double tap.</param>
410404
public static void DoubleTapCoordinates(this IApp app, float x, float y)
411405
{
412-
app.CommandExecutor.Execute("doubleTapCoordinates", new Dictionary<string, object>
406+
if (app is AppiumCatalystApp)
413407
{
414-
{ "x", x },
415-
{ "y", y }
416-
});
408+
app.DoubleClickCoordinates(x, y); // Directly invoke coordinate-based double click for AppiumCatalystApp.
409+
}
410+
else
411+
{
412+
app.CommandExecutor.Execute("doubleTapCoordinates", new Dictionary<string, object>
413+
{
414+
{ "x", x },
415+
{ "y", y }
416+
});
417+
}
417418
}
418419

419420
/// <summary>
@@ -1422,11 +1423,18 @@ public static void ClickCoordinates(this IApp app, float x, float y)
14221423
/// <param name="y">The y coordinate to tap.</param>
14231424
public static void TapCoordinates(this IApp app, float x, float y)
14241425
{
1425-
app.CommandExecutor.Execute("tapCoordinates", new Dictionary<string, object>
1426+
if (app is AppiumCatalystApp)
14261427
{
1427-
{ "x", x },
1428-
{ "y", y }
1429-
});
1428+
app.ClickCoordinates(x, y); // // Directly invoke coordinate-based click for AppiumCatalystApp.
1429+
}
1430+
else
1431+
{
1432+
app.CommandExecutor.Execute("tapCoordinates", new Dictionary<string, object>
1433+
{
1434+
{ "x", x },
1435+
{ "y", y }
1436+
});
1437+
}
14301438
}
14311439

14321440
/// <summary>

0 commit comments

Comments
 (0)