Atata 2.9.0 is Released

August 31, 2023 by Yevgeniy Shunevych


Atata 2.9.0 is released with browser logs monitoring, JS popup boxes handling and other improvements.

Changelog

New features

  • minor #760 Add FindByRelativeElementContentAttribute
  • minor #761 Add FindByPrecedingSiblingContentAttribute
  • minor #762 Add DriverDeInitEvent
  • minor #763 Add RaiseError and RaiseWarning methods to AtataContext
  • major #764 Add browser logs monitoring functionality
  • major #766 Add functionality for JavaScript popup boxes (alert, confirm, prompt)

Changes and enhancements

  • minor #759 Add indentation and line breaks to complex object strings in expected and actual error messages
  • major #765 Use Selenium.WebDriver package v4.11.0

Fixes

  • fix #758 Incorrect name of ControlList<TItem, TOwner>.Count property in log

Browser logs monitoring functionality

Currently this functionality is available only for Chrome and Edge.

The feature brings a monitoring of browser logs, such as warnings and errors, which happen during a test execution. Browser logs can be transferred to Atata logs and can raise warnings.

In order to enable browser logs monitoring, configure AtataContext in the following way:

AtataContext.GlobalConfiguration
    .BrowserLogs.UseLog()
    .BrowserLogs.UseMinLevelOfWarning(LogLevel.Warn);

UseLog(bool enable = true) - sets a value indicating whether the browser log should be transferred to Atata logging system. The default value is false.

UseMinLevelOfWarning(LogLevel? minLevel) - sets the minimum log level on which to raise warnings. The default value is null, meaning that warning is disabled. For example, setting the LogLevel.Warn value will mean to warn on browser log entries with LogLevel.Warn level and higher, which are LogLevel.Error and LogLevel.Fatal.

A log entry in Atata log can look like:

2023-08-26 20:41:49.3187 TRACE - Browser log: 20:41:49.2800 ERROR http://localhost:54321/browserlogs 17:10 Uncaught Error: Some thrown error.

A warning looks this way:

Unexpected browser log error on "<ordinary>" page:
http://localhost:54321/browserlogs 17:10 Uncaught Error: Some thrown error.

Handling JavaScript popup boxes (alert, confirm, prompt)

Introduces the Atata fluent API for handling JavaScript popup boxes.

Added 3 new methods to PageObject<TOwner>:

public AlertBox<TOwner> SwitchToAlertBox(TimeSpan? waitTimeout = null, TimeSpan? waitRetryInterval = null);

public ConfirmBox<TOwner> SwitchToConfirmBox(TimeSpan? waitTimeout = null, TimeSpan? waitRetryInterval = null);

public PromptBox<TOwner> SwitchToPromptBox(TimeSpan? waitTimeout = null, TimeSpan? waitRetryInterval = null);

The methods wait and switch to the open popup box. By default, if waitTimeout and waitRetryInterval arguments are not specified, the AtataContext.WaitingTimeout and AtataContext.WaitingRetryInterval values are used correspondingly. If popup box does not appear within the specified time, the TimeoutException is thrown.

Alert

Go.To<SomePage>()
    .AlertButton.Click()
    .SwitchToAlertBox()
    .Accept();

Confirm

Go.To<SomePage>()
    .ConfirmButton.Click()
    .SwitchToConfirmBox()
    .Accept(); // or Cancel()

Prompt

Go.To<SomePage>()
    .PromptButton.Click()
    .SwitchToPromptBox()
    .Type("Some text")
    .Accept(); // or Cancel()

Verify popup text

Use Text property of popup box classes to get or verify the text of popup.

page.SwitchToAlertBox()
    .Text.Should.Be("Some text");