-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UITest: Add UIAssert.NotExists method and extend a test
- Loading branch information
Showing
2 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using FlaUI.Core.Tools; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace UITest.Writer; | ||
|
||
public class ElementFoundException(string message, Exception? innerException = null) : Exception(message, innerException) { } | ||
|
||
public static class UIAssert | ||
{ | ||
public static void NotExists(Action accessElement, [CallerArgumentExpression(nameof(accessElement))]string? argumentExpression = null) | ||
{ | ||
var notFound = false; | ||
var timeout = Retry.DefaultTimeout; | ||
Retry.DefaultTimeout = TimeSpan.Zero; | ||
try | ||
{ | ||
|
||
accessElement(); | ||
} | ||
catch (ElementNotFoundException) | ||
{ | ||
notFound = true; | ||
} | ||
finally | ||
{ | ||
Retry.DefaultTimeout = timeout; | ||
} | ||
if (!notFound) throw new ElementFoundException($"Element found with '{argumentExpression}'"); | ||
} | ||
} |