Atata 2.5.0 is released with new verification methods and a control focused state.
Changelog
New Features
- major
#706 Add
IsFocusedproperty toControl<TOwner> - minor
#707 Add
Resolveoverloaded method toUIComponentChildrenList<TOwner> - minor
#709 Add
ForEachextension method forIObjectProvider<IEnumerable<TSource>, TOwner> - minor
#710 Add
ContainsandContainsAnyextension methods forIObjectProvider<IEnumerable<TSource>> - major
#712 Add
ContainAnyverification extension methods forIEnumerable<T> - major
#713 Add
StartWithAnyverification extension methods forIEnumerable<T> - major
#714 Add
StartWithAnyverification extension methods forstring - major
#715 Add
EndWithAnyverification extension methods forstring - major
#716 Add
EndWithAnyverification extension methods forIEnumerable<T> - major
#717 Add
StartWithverification extension methods forIEnumerable<T> - major
#718 Add
EndWithverification extension methods forIEnumerable<T> - major
#721 Add
IEqualityComparer<T>support to verification functionality - major
#723 Add
ConsistOnlyOfverification extension methods forIEnumerable<T> - major
#724 Add
ConsistOfverification extension methods forIEnumerable<T> - major
#725 Add
Match(string, RegexOptions)overloaded verification extension method forstring - major
#727 Add
BeFocusedverification extension method forControl<TOwner>
Changes and Enhancements
- minor
#704 Update
PressKeysAttributeto usePageObject<TOwner>.Pressmethod - minor
#705 Make
PressKeysAttributeinheritors to inheritTriggerAttributedirectly - minor
#711 Change
IEnumerableobject string representation in verification messages - minor
#719 Remove
argsparameter fromSatisfyverification extension method forIEnumerable<T> - minor
#722 Change default string comparison from
StringComparison.CurrentCulturetoStringComparison.Ordinalin verification functionality - major #726 Use Selenium.WebDriver package v4.7.0
Fixes
- fix #708
BeEquivalentandEqualSequenceverification methods should not throw when expected is an empty enumerable - fix #720
BeEquivalentverification 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;