PlaywrightPercySDK 1.0.1

dotnet add package PlaywrightPercySDK --version 1.0.1                
NuGet\Install-Package PlaywrightPercySDK -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PlaywrightPercySDK" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PlaywrightPercySDK --version 1.0.1                
#r "nuget: PlaywrightPercySDK, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PlaywrightPercySDK as a Cake Addin
#addin nuget:?package=PlaywrightPercySDK&version=1.0.1

// Install PlaywrightPercySDK as a Cake Tool
#tool nuget:?package=PlaywrightPercySDK&version=1.0.1                

PlaywrightPercy

This SDK provides Integration of Playwright C# test project with BrowserStack Percy.

Pre-Requisites

Getting Started with Custom SDK - Updating the code

dotnet add package PlaywrightPercySDK --version 1.0.0
  • Update your test file by adding references to SDK
using PlaywrightPercy;
  • Initialise PercyHelper Class Object in your test file
PercyHelper helper = new PercyHelper();
  • Finally call the method "CapturePercyScreenshotAsync" by passing your Page object and name for the screenshot:
    [TestMethod]
    public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
    {
        await Page.GotoAsync("https://www.google.com");
        await helper.CapturePercyScreenshotAsync(Page, "firstscreenshot");
    }
  • Complete test class will look similar to this:
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Playwright;
using Microsoft.Playwright.MSTest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
using PlaywrightPercy;
using RestSharp;

namespace PlaywrightTests;

[TestClass]
public class UnitTest1 : PageTest
{
    // Initialise the Percy Helper class 
    PercyHelper helper = new PercyHelper();

    [TestMethod]
    public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
    {
        await Page.GotoAsync("https://www.google.com");
        // Call the CapturePercyScreenshotAsync method
        await helper.CapturePercyScreenshotAsync(Page, "firstscreenshot");
    }
}

Run the Tests

  • Install Percy CLI by running the following command on your terminal/commad prompt:
npm i @percy/cli -g
  • Set the environment variable with Percy Token (as captured in pre-requisites):
export PERCY_TOKEN=<<YOUR PERCY_TOKEN>>
  • Set the PErcy build environment variable (your branch)
export PERCY_BRANCH=local
  • Start Percy CLI by running following command on terminal/command prompt:
npx percy exec:start
  • Run your dotnet test
  • After successful tests, stop the percy CLI by closing the terminal.
  • Verify the build in Percy Web and you should be able to see the screenshot with given name associated in the percy build.
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 240 12/14/2023

Initial Version for Testing