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 - 16 #26029

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

anandhan-rajagopal
Copy link
Contributor

@anandhan-rajagopal anandhan-rajagopal commented Nov 21, 2024

Description of Change

This PR focuses on re-enabling and updating following tests from the Xamarin.UITest framework to be compatible with Appium. The tests, previously commented out, are reviewed, and modified to ensure they are functional with the Appium framework. We are going to enable tests in blocks in different PRs. This is the 16th group of tests enabled.

Add WaitForElementTillPageNavigationSettled Extension Method

Description

Also introduces a new extension method WaitForElementTillPageNavigationSettled to enhance the stability of UI tests, particularly for MacCatalyst applications. The method provides a more robust way to wait for elements during page transitions, helping to prevent null reference exceptions.

TestCases

  • Bugzilla38731
  • Bugzilla32040
  • Bugzilla39331
  • Bugzilla43527
  • Bugzilla40173
  • Bugzilla40005
  • Bugzilla10222
  • Bugzilla52419
  • Bugzilla45926

@rmarinho
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@mattleibow mattleibow added the area-testing Unit tests, device tests label Nov 21, 2024
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS && TEST_FAILS_ON_WINDOWS //Issue reproduced and logged: https://github.com/dotnet/maui/issues/26019.
Copy link
Contributor

Choose a reason for hiding this comment

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

The issue was a duplicated and has been closed, could you update the comment to replace it by #26026?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced the issue link and committed the changes, kindly review and share your feedback.

/// <param name="app">The IApp instance.</param>
/// <param name="elementId">The id of the element to wait for.</param>
/// <param name="timeout">Optional timeout for the wait operation. Default is null, which uses the default timeout.</param>
public static void WaitForElementTillPageNavigationSettled(this IApp app, string elementId, TimeSpan? timeout = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could include another override passing IQuery query as parameter instead the elementId? In that way we can wait for elements based on a query.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your suggestion. I've added an override method WaitForElementTillPageNavigationSettled which accepts the query parameter.
Please kindly review and share your feedback or have additional suggestions.

app.Tap(AppiumQuery.ByAccessibilityId("NavigationViewBackButton"));
/// <param name="app">The IApp instance representing the main gateway to interact with the application.</param>
/// <param name="customBackButtonIdentifier">Optional. The custom identifier for the back button. If not provided, default platform-specific identifiers will be used.</param>
public static void TapBackArrow(this IApp app, string customBackButtonIdentifier = "")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not split in two methods?

static void TapBackArrow(this IApp app);
static void TapBackArrow(this IApp app, IQuery query);

The first one will just use the default platform-specific identifiers and the second one will allow any custom query like for example AppiumQuery.ByAccessibilityId("Back")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your suggestion. I've refactored the code into three methods:

  1. TapBackArrow(this IApp app)
  2. TapBackArrow(this IApp app, string customBackButtonIdentifier)
  3. TapBackArrow(this IApp app, IQuery query)

Please kindly review and share your feedback or have additional suggestions.

App.WaitForElementTillPageNavigationSettled(PushNewPage);
App.Tap(PushNewPage);
App.WaitForElementTillPageNavigationSettled(TabPage2);
App.Tap(TabPage2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Mnnn, maybe I could include a TapTab method that internally does the wait, and also in the case of Android the ToUpperCase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-testing Unit tests, device tests community ✨ Community Contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants