Skip to content

Commit

Permalink
#698 Add page snapshot functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
YevgeniyShunevych committed Nov 16, 2022
1 parent 14d4bf3 commit 5c1a245
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
Expand Up @@ -45,7 +45,7 @@ public PageSnapshotsAtataContextBuilder UseStrategy(IPageSnapshotStrategy strate

/// <summary>
/// Sets the file name template of page snapshots.
/// The default value is <c>"{snapshot-number:D2} - {snapshot-pageobjectname} {snapshot-pageobjecttypename}{snapshot-title: - *}"</c>.
/// The default value is <c>"{snapshot-number:D2}{snapshot-pageobjectname: - *}{snapshot-pageobjecttypename: *}{snapshot-title: - *}"</c>.
/// </summary>
/// <param name="fileNameTemplate">The file name template.</param>
/// <returns>The <see cref="PageSnapshotsAtataContextBuilder"/> instance.</returns>
Expand Down
4 changes: 2 additions & 2 deletions src/Atata/Context/PageSnapshots/PageSnapshotsConfiguration.cs
Expand Up @@ -16,10 +16,10 @@ public sealed class PageSnapshotsConfiguration : ICloneable
/// <summary>
/// Gets or sets the page snapshot file name template.
/// The file name is relative to Artifacts path.
/// The default value is <c>"{snapshot-number:D2} - {snapshot-pageobjectname} {snapshot-pageobjecttypename}{snapshot-title: - *}"</c>.
/// The default value is <c>"{snapshot-number:D2}{snapshot-pageobjectname: - *}{snapshot-pageobjecttypename: *}{snapshot-title: - *}"</c>.
/// </summary>
public string FileNameTemplate { get; set; } =
"{snapshot-number:D2} - {snapshot-pageobjectname} {snapshot-pageobjecttypename}{snapshot-title: - *}";
"{snapshot-number:D2}{snapshot-pageobjectname: - *}{snapshot-pageobjecttypename: *}{snapshot-title: - *}";

/// <inheritdoc cref="Clone"/>
object ICloneable.Clone() => Clone();
Expand Down
6 changes: 3 additions & 3 deletions src/Atata/Logging/Snapshots/PageSnapshotTaker.cs
Expand Up @@ -49,9 +49,9 @@ private string FormatFilePath(string title)
{
["snapshot-number"] = _snapshotNumber,
["snapshot-title"] = title,
["snapshot-pageobjectname"] = pageObject.ComponentName,
["snapshot-pageobjecttypename"] = pageObject.ComponentTypeName,
["snapshot-pageobjectfullname"] = pageObject.ComponentFullName
["snapshot-pageobjectname"] = pageObject?.ComponentName,
["snapshot-pageobjecttypename"] = pageObject?.ComponentTypeName,
["snapshot-pageobjectfullname"] = pageObject?.ComponentFullName
};

return AtataContext.Current.FillPathTemplateString(_filePathTemplate, snapshotVariables);
Expand Down
21 changes: 21 additions & 0 deletions test/Atata.IntegrationTests/Context/AtataContextTests.cs
Expand Up @@ -193,4 +193,25 @@ public class FillTemplateString : UITestFixtureBase
_sut.ResultOf(x => x.FillTemplateString("start_{missingkey}_end"))
.Should.Throw<FormatException>();
}

public class TakePageSnapshot : UITestFixture
{
[Test]
public void WhenNavigated()
{
Go.To<InputPage>();

AtataContext.Current.TakePageSnapshot();

AtataContext.Current.Artifacts.Should.ContainFile("01 - Input page.mhtml");
}

[Test]
public void WhenNoNavigation()
{
AtataContext.Current.TakePageSnapshot();

AtataContext.Current.Artifacts.Should.ContainFile("01.mhtml");
}
}
}

0 comments on commit 5c1a245

Please sign in to comment.