FluentAutomation icon indicating copy to clipboard operation
FluentAutomation copied to clipboard

FindMultiple now throws an exception if nothing is found

Open AnthonySteele opened this issue 11 years ago • 2 comments

I have just updated to V 3.0. I was using FindMultiple to check if the test was already signed in as a precondition to running the tests; this can result from a failure during the previous test run. I used this code:

var signoutButtons = homePage.I.FindMultiple(SignOutButton).Elements;
if (signoutButtons.Any())
{
    // click the signout button
}

There seems to be a breaking change where this code now throws a FluentElementNotFoundException rather than returning a collection containing zero elements.

What is he preferred way to do this?

AnthonySteele avatar May 28 '14 17:05 AnthonySteele

Ya, It was effectively a bug in the 2.x branch that we couldn't change until the next major revision.

Both I.Find and I.FindMultiple now throw FluentElementNotFoundException when there are no matching items on the page and they are evaluated. The .Elements collection basically evaluates on access.

To check existence, use the .Children collection instead. If its empty, no elements were found. Kind of awkward naming but the Elements collection became far more complex to deal with MultiBrowser bits for 3.0.

stirno avatar May 28 '14 18:05 stirno

Thanks for the quick reply. In this case, the Children collection seems to have one element in it, of type System.Func<FluentAutomation.ElementProxy> and I am fairly sure that the logout button is not visible.

AnthonySteele avatar May 29 '14 09:05 AnthonySteele