Atata 1.4.0 is released with fluent waitings, warnings and other new useful features.
Changelog
New Features
- major #318 Expectation verification functionality
- major #319 Waiting verification functionality
- minor
#320 Add
WaitingTriggerAttribute
- major
#321 Add
WaitUntilEnabledAttribute
trigger - major
#323 Add
FindByScriptAttribute
- minor
#324 Add overloaded collection verification methods with
IEnumerable
argument - minor
#328 Add
FindByDescendantAttributeAttribute
- minor
#329 Add
FindByDescendantIdAttribute
- minor
#330 Add
ValueGetFormatAttribute
- minor
#331 Add
ValueSetFormatAttribute
- minor
#332 Add
UseNUnitAssertionExceptionType
method toAtataContextBuilder
- major
#333 Add
UseAllNUnitFeatures
method toAtataContextBuilder
Waiting Verification
The new functionality is here to provide fluent waitings.
Usage
The usage is similar to Atata’s Should
assertions.
Just use WaitTo
instead of Should
:
Component.WaitTo.Equal("...")
Component.WaitTo.BeVisible()
Component.WaitTo.BeEnabled()
If a condition is not met during the waiting time, which is taken from AtataContext
by default (AtataContext.Current.WaitingTimeout
and AtataContext.Current.WaitingRetryInterval
), then TimeoutException
is thrown.
Expectation Verification
The new functionality is here to provide warnings. This functionality is similar to the meaning of “soft assertions” term.
If the test you are writing is quite complex and you need to do several assertions during the test flow without breaking the test with assertion exception when the first assertion fails, the expectation functionality is for the help.
Usage
The usage is similar to Atata’s Should
assertions.
Just use ExpectTo
instead of Should
:
Component.ExpectTo.Equal("...")
It doesn’t throw an exception on failure, but write the warning assertion result to the log and adds it to AtataContext.Current.PendingFailureAssertionResults
collection.
When on TearDown
AtataContext.Current?.CleanUp()
is invoked,
after the actual cleaning it will throw aggregate assertion exception with all found ExpectTo
errors.
When using NUnit (AtataContextBuilder.UseNUnitWarningReportStrategy()
),
it will record every expectation failure as NUnit warning, which is similar.
It is also absolutely valid to use expectations inside AggregateAssert
sections.
Configuration
The following methods are added to AtataContextBuilder
for configuring expectation verification functionality:
public AtataContextBuilder UseWarningReportStrategy(IWarningReportStrategy strategy);
public AtataContextBuilder UseNUnitWarningReportStrategy();
When using NUnit, it is available to invoke UseNUnitWarningReportStrategy()
during AtataContext
configuration
in order to record warnings as NUnit’s built-in warnings.
For other testing frameworks (xUnit, MSTest) the native Atata expectation functionality will work well by default.
Note that not all test runners support/recognize NUnit warnings (for example Visual Studio 2019 test explorer does not for now, while 2015 and 2017 do).
New FindByScriptAttribute
FindByScriptAttribute
- specifies that a control should be found by specific script. The script should return an element or collection of elements. The script can also return null
for the case when the element is not found. The scope element is passed to the script as an argument and can be used in the script as arguments[0]
.
Usage
Find in the Scope of Parent
[FindByScript("return arguments[0].querySelector('span.someclass')")]
public Control<_> SomeControl { get; private set; }
Find in the Scope of Whole Page
[FindByScript("return document.querySelector('input[type=radio][value=OptionA]')")]
public RadioButton<_> OptionA { get; private set; }
New UseAllNUnitFeatures Method
New method is added to AtataContextBuilder
:
public AtataContextBuilder UseAllNUnitFeatures();
Enables all NUnit features for Atata. Executes the following methods:
UseNUnitTestName()
UseNUnitAssertionExceptionType()
UseNUnitAggregateAssertionStrategy()
UseNUnitWarningReportStrategy()
AddNUnitTestContextLogging()
LogNUnitError()
TakeScreenshotOnNUnitError()