Atata 2.5.0 is Released

December 22, 2022 by Yevgeniy Shunevych


Atata 2.5.0 is released with new verification methods and a control focused state.

Changelog

New Features

  • major #706 Add IsFocused property to Control<TOwner>
  • minor #707 Add Resolve overloaded method to UIComponentChildrenList<TOwner>
  • minor #709 Add ForEach extension method for IObjectProvider<IEnumerable<TSource>, TOwner>
  • minor #710 Add Contains and ContainsAny extension methods for IObjectProvider<IEnumerable<TSource>>
  • major #712 Add ContainAny verification extension methods for IEnumerable<T>
  • major #713 Add StartWithAny verification extension methods for IEnumerable<T>
  • major #714 Add StartWithAny verification extension methods for string
  • major #715 Add EndWithAny verification extension methods for string
  • major #716 Add EndWithAny verification extension methods for IEnumerable<T>
  • major #717 Add StartWith verification extension methods for IEnumerable<T>
  • major #718 Add EndWith verification extension methods for IEnumerable<T>
  • major #721 Add IEqualityComparer<T> support to verification functionality
  • major #723 Add ConsistOnlyOf verification extension methods for IEnumerable<T>
  • major #724 Add ConsistOf verification extension methods for IEnumerable<T>
  • major #725 Add Match(string, RegexOptions) overloaded verification extension method for string
  • major #727 Add BeFocused verification extension method for Control<TOwner>

Changes and Enhancements

  • minor #704 Update PressKeysAttribute to use PageObject<TOwner>.Press method
  • minor #705 Make PressKeysAttribute inheritors to inherit TriggerAttribute directly
  • minor #711 Change IEnumerable object string representation in verification messages
  • minor #719 Remove args parameter from Satisfy verification extension method for IEnumerable<T>
  • minor #722 Change default string comparison from StringComparison.CurrentCulture to StringComparison.Ordinal in verification functionality
  • major #726 Use Selenium.WebDriver package v4.7.0

Fixes

  • fix #708 BeEquivalent and EqualSequence verification methods should not throw when expected is an empty enumerable
  • fix #720 BeEquivalent verification extension methods for IEnumerable<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;