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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PlaywrightPercy
This SDK provides Integration of Playwright C# test project with BrowserStack Percy.
Pre-Requisites
- Node and NPM installed on your machine/agent (in case running in CI/CD pipelines)
- BrowserStack access with Percy Web
- Existing Percy Project Setup in BrowserStack and copy the PERCY_TOKEN : https://www.browserstack.com/docs/percy/get-started/create-project
- Existing Playwright C# project. If you do not have one refer: https://playwright.dev/dotnet/docs/intro
Getting Started with Custom SDK - Updating the code
- Add reference to Nuget package in your project or refer https://www.nuget.org/packages/PlaywrightPercySDK/ other options
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 | Versions 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.
-
net7.0
- Microsoft.Playwright (>= 1.40.0)
- Newtonsoft.Json (>= 13.0.3)
- RestSharp (>= 110.2.0)
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 | 237 | 12/14/2023 |
Initial Version for Testing