Atata 2.5.0 is released with new verification methods and a control focused state.
Changelog
New Features
- major
#706 Add
IsFocused
property toControl<TOwner>
- minor
#707 Add
Resolve
overloaded method toUIComponentChildrenList<TOwner>
- minor
#709 Add
ForEach
extension method forIObjectProvider<IEnumerable<TSource>, TOwner>
- minor
#710 Add
Contains
andContainsAny
extension methods forIObjectProvider<IEnumerable<TSource>>
- major
#712 Add
ContainAny
verification extension methods forIEnumerable<T>
- major
#713 Add
StartWithAny
verification extension methods forIEnumerable<T>
- major
#714 Add
StartWithAny
verification extension methods forstring
- major
#715 Add
EndWithAny
verification extension methods forstring
- major
#716 Add
EndWithAny
verification extension methods forIEnumerable<T>
- major
#717 Add
StartWith
verification extension methods forIEnumerable<T>
- major
#718 Add
EndWith
verification extension methods forIEnumerable<T>
- major
#721 Add
IEqualityComparer<T>
support to verification functionality - major
#723 Add
ConsistOnlyOf
verification extension methods forIEnumerable<T>
- major
#724 Add
ConsistOf
verification extension methods forIEnumerable<T>
- major
#725 Add
Match(string, RegexOptions)
overloaded verification extension method forstring
- major
#727 Add
BeFocused
verification extension method forControl<TOwner>
Changes and Enhancements
- minor
#704 Update
PressKeysAttribute
to usePageObject<TOwner>.Press
method - minor
#705 Make
PressKeysAttribute
inheritors to inheritTriggerAttribute
directly - minor
#711 Change
IEnumerable
object string representation in verification messages - minor
#719 Remove
args
parameter fromSatisfy
verification extension method forIEnumerable<T>
- minor
#722 Change default string comparison from
StringComparison.CurrentCulture
toStringComparison.Ordinal
in verification functionality - major #726 Use Selenium.WebDriver package v4.7.0
Fixes
- fix #708
BeEquivalent
andEqualSequence
verification methods should not throw when expected is an empty enumerable - fix #720
BeEquivalent
verification extension methods forIEnumerable<T>
are false positive for some cases
New Verification Methods
A bunch of new verification methods were added. A list of all verification methods can be found on newly added Verification Methods page.
For IEnumerable<T>
-
ContainAny
(params TObject[] expected) -
ContainAny
(IEnumerable<TObject> expected) -
StartWith
(params TObject[] expected) -
StartWith
(IEnumerable<TObject> expected) -
StartWithAny
(params TObject[] expected) -
StartWithAny
(IEnumerable<TObject> expected) -
EndWith
(params TObject[] expected) -
EndWith
(IEnumerable<TObject> expected) -
EndWithAny
(params TObject[] expected) -
EndWithAny
(IEnumerable<TObject> expected) -
ConsistOf
(params Expression <Func <TObject, bool>>[] predicateExpressions) -
ConsistOnlyOf
(Expression <Func <TObject, bool>> predicateExpression) -
ConsistOnlyOf
(Func <TObject, bool> predicate, string message) -
ConsistOnlyOf
(TObject expected)
Usage
var sut = new [] { 1, 2, 3, 4 }.ToSutSubject();
sut.Should.ContainAny(3, 4, 5);
sut.Should.StartWith(1, 2);
sut.Should.StartWithAny(0, 1);
sut.Should.EndWith(3, 4);
sut.Should.EndWithAny(4, 5);
sut.Should.ConsistOf(x => x > 0, x => x == 3, x => x == 1, x => x < 4);
sut.Should.ConsistOnlyOf(x => x > 0 && x < 10);
sut.Should.ConsistOnlyOf(x => x > 0, "are positive");
sut.Should.Not.ConsistOnlyOf(1);
sut.Should.Not.ConsistOfSingle(x => x == 1);
For String
-
StartWithAny
(params string[] expected) -
StartWithAny
(IEnumerable<string> expected) -
EndWithAny
(params string[] expected) -
EndWithAny
(IEnumerable<string> expected) -
Match
(string pattern, RegexOptions regexOptions)
Usage
var sut = "Hello World".ToSutSubject();
sut.Should.Match("^hello", RegexOptions.IgnoreCase);
sut.Should.StartWithAny("Hi", "Hello");
sut.Should.EndWithAny("World", "Planet");
New Verification Features
Ignore String Case
In order to ignore string case during verification, use IgnoringCase
property:
page.SomeInput.Should.IgnoringCase.Equal("some value");
page.SomeStringList.Should.IgnoringCase.EqualSequence("a", "b", "c");
Equality Comparison
It is possible to customize the comparison of objects, mostly complex objects. Also this can be used for approximate comparison of values.
The base VerificationProvider<TVerificationProvider, TOwner>
provides the following method:
public TVerificationProvider Using<T>(IEqualityComparer<T> equalityComparer);
Usage
page.SomeNumberInput.Should.Using(new CustomNumberEqualityComparer()).Equal(10.5);
Control Focused State
A property is added to Control<TOwner>
to check whether the control is focused:
public ValueProvider<bool, TOwner> IsFocused { get; }
Also BeFocused
verification extension method is added for Control<TOwner>
.
Usage
page.SomeInput.Should.Not.BeFocused();
page.SomeInput.Focus();
page.SomeInput.Should.BeFocused();
bool isInputFocused = page.SomeInput.IsFocused;