Atata 2.8.0 is Released

June 22, 2023 by Yevgeniy Shunevych


Atata 2.8.0 is released with full-page screenshots, new FindByTestIdAttribute and other improvements.

Due to a bug, it is recommended to use version 2.8.1, which has a fix.

Changelog

New features

  • major #749 Add full-page screenshot functionality
  • minor #751 Add FindByAriaLabelAttribute
  • minor #752 Add FindByAriaLabelledByAttribute
  • major #755 Add FindByTestIdAttribute

Changes and enhancements

  • major #748 Use Selenium.WebDriver package v4.10.0
  • minor #750 Correct typos in member names
  • minor #753 Inherit Link<TOwner> from Text<TOwner>
  • minor #754 Rename ViewPort members to Viewport
  • major #756 Retry UI actions on StaleElementReferenceException

Full-page screenshot functionality

Adds a possibility to take full-page screenshots. The functionality is not enabled by default. Also, currently it works only for Chrome, Edge and Firefox, so enable it carefully.

Enable full-page screenshots by default

Full-page screenshots can be enabled to be taken by default instead of viewport screenshots.

Configuration

A property is added to AtataContextBuilder:

public ScreenshotsAtataContextBuilder Screenshots { get; }

ScreenshotsAtataContextBuilder contains the following methods:

// Used by default.
public ScreenshotsAtataContextBuilder UseWebDriverViewportStrategy();

// Works only for Firefox.
public ScreenshotsAtataContextBuilder UseWebDriverFullPageStrategy();

// Works only for Chrome and Edge.
public ScreenshotsAtataContextBuilder UseCdpFullPageStrategy();

// *** Recommended to use for full-page screenshots, regardless of browser/driver.
public ScreenshotsAtataContextBuilder UseFullPageOrViewportStrategy();

// To use custom strategy.
public ScreenshotsAtataContextBuilder UseStrategy(IScreenshotStrategy strategy);
Usage
AtataContext.GlobalConfiguration
    .Screenshots.UseFullPageOrViewportStrategy();

Explicitly take full-page screenshots

It is also possible to take full-page screenshots only at certain points. It is allowed to explicitly specify ScreenshotKind enum value depending whether you need a viewport or a full-page screenshot.

ScreenshotKind enum provides 3 values: Default, Viewport and FullPage.

Examples

AtataContext.Current.TakeScreenshot(ScreenshotKind.FullPage);
Go.To<SomePage>()
    .Report.Screenshot(ScreenshotKind.FullPage);
[TakeScreenshot(ScreenshotKind.FullPage, TriggerEvents.Init)]
AtataContext.GlobalConfiguration
    .TakeScreenshotOnNUnitError(ScreenshotKind.FullPage);

New FindByTestIdAttribute

FindByTestIdAttribute - specifies that a control should be found by the DOM test identifier attribute, data-testid by default. Finds the control that has the test identifier attribute matching the specified term(s). Uses TermCase.Kebab as the default term case.

Usage

[FindByTestId] // Will look for a text input with '[data-testid="first-name"]'
public TextInput<_> FirstName { get; private set; }

[FindByTestId("last-name")]
public TextInput<_> LastName { get; private set; }

Configuration

The methods added to AtataContextBuilder for test identifier configuration:

public AtataContextBuilder UseDomTestIdAttributeName(string name);

public AtataContextBuilder UseDomTestIdAttributeDefaultCase(TermCase defaultCase);

Example

AtataContext.GlobalConfiguration
    .UseDomTestIdAttributeName("data-autoid")
    .UseDomTestIdAttributeDefaultCase(TermCase.PascalKebab);

New attributes for ARIA

  • FindByAriaLabelAttribute - specifies that a control should be found by the aria-label attribute. Finds the control that has the aria-label attribute matching the specified term(s). Uses TermCase.Sentence as the default term case.
  • FindByAriaLabelledByAttribute - specifies that a control should be found by the aria-labelledby attribute. Finds the control that has the aria-labelledby attribute matching the specified term(s). Uses TermCase.Kebab as the default term case.

Retry UI actions on StaleElementReferenceException

Before, rarely when DOM is dynamically updated StaleElementReferenceException can occur during UI actions. StaleElementReferenceException was handled for components element finding, waiting and assertion, but not for actions like click, type, etc. Now all UI actions are also covered with retries to produce more reliable interactions.