Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 27, 2025

This PR ports the fix from MAUI PR #31218 to align the behavior of WaitForTextToBePresentInElement with other wait methods in the library.

Problem

The WaitForTextToBePresentInElement method was silently returning false when the expected text was not found within the timeout period, instead of throwing a TimeoutException like other wait methods. This caused tests to pass silently when they should fail, leading to false positive test results.

// Before: Method would return false on timeout, causing silent test failures
app.WaitForTextToBePresentInElement("MyElement", "Expected Text");
// Test continues even if text was never found

Solution

The method now throws a TimeoutException with a descriptive message when the timeout is reached, aligning with the behavior of other wait methods like WaitForElement, WaitForNoElement, etc.

// After: Method throws TimeoutException on timeout, properly failing the test
app.WaitForTextToBePresentInElement("MyElement", "Expected Text");
// Test fails with clear error message if text is not found

Changes

  • Before: return false; on timeout
  • After: throw new TimeoutException($"Timed out waiting for text '{text}' to be present in element with automation id '{automationId}'.");

This change ensures that UI tests fail properly when expected conditions are not met, preventing false positive test results while maintaining backward compatibility since existing usage patterns don't typically check the return value of wait methods.

Fixes #58.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Port change from MAUI Fix WaitForTextToBePresentInElement to throw TimeoutException instead of returning false Aug 27, 2025
@Copilot Copilot AI requested a review from jfversluis August 27, 2025 12:25
Copilot finished work on behalf of jfversluis August 27, 2025 12:25
@jfversluis jfversluis marked this pull request as ready for review August 27, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port change from MAUI

2 participants