Skip to main content

Integrate your Appium with C# test suite with App Percy

A guide to integrating your Appium and C-Sharp automated tests with BrowserStack App Percy. Catch visual differences in your web application on time.

We highly recommend using our BrowserStack SDK for Percy integration.

Prerequisites

In order to conduct Percy visual testing for .NET Appium, you must possess the following NuGet package dependencies:

  • Appium version < 2.0.1
  • Node 12+ with npm
  • Appium.WebDriver Version >= 4.0 and < 5
  • Newtonsoft.Json Version >= 12.0.1
  • Castle.Core Version >= 4.3.1
  • Microsoft.CSharp Version >= 4.7.0
  • DotNetSeleniumExtras.WaitHelpers

Integrate App Percy with your test suite to run visual tests. To do that, follow these steps:

Create new app project on percy dashboard

Sign in to Percy and create a new app type project. After you’ve created the project, you’ll be shown a PERCY_TOKEN environment variable. Percy will use the PERCY_TOKEN to know which organisation and project to upload the screenshots to. You will need this PERCY_TOKEN in next steps.

Create an App Percy project

Set the project token as an environment variable

Run the given command to set PERCY_TOKEN as an environment variable:

Copy icon Copy snippet

Install Percy packages

Install Percy CLI by running the following command:

Copy icon Copy snippet

Install dependencies

Install the PercyIO.Appium package (for example, with .NET CLI):

Copy icon Copy snippet

Update test script

Make sure to import PercyIO.Appium in your code.

Below is an example test using the percy’s Screenshot method. Use this function wherever you have to take a screenshot.

Copy icon Copy snippet

We are passing the required arguments.percy.screenshot method.

The screenshot method arguments are:

Copy icon Copy snippet
  • name (required) - The screenshot name; must be unique to each screenshot
  • Additional screenshot options (overrides any project options):
  • fullScreen - It indicates if the app is a full screen
  • options - Optional screenshot params: Use ScreenshotOptions to set following params to override
  • DeviceName - Device name on which screenshot is taken
  • StatusBarHeight - Height of status bar for the device
  • NavBarHeight - Height of navigation bar for the device
  • Orientation - Orientation of the application
  • FullPage: true/false [alpha] only supported on App Automate driver sessions [needs @percy/cli 1.20.2+ ]
  • In case scrollview is overlapping with other app elements. Offsets can be provided to reduce the area which needs to be considered for scrolling:
    • TopScrollviewOffset: (optional) - [alpha] offset from top of scrollview [ needs @percy/cli 1.20.2+ ]; int
    • BottomScrollviewOffset (optional) - [alpha] offset from bottom of scrollview [ needs @percy/cli 1.20.2+ ]; int
  • ScreenLengths: int [alpha] max screen lengths for fullPage [ needs @percy/cli 1.20.2+ ]
  • ScrollableXpath (optional) - [alpha] scrollable element xpath for fullpage [ needs @percy/cli 1.20.2+ ]; string
  • ScrollableId (optional) - [alpha] scrollable element accessibility id for fullpage [ needs @percy/cli 1.20.2+ ]; string
  • IgnoreRegionXpaths (optional) - elements xpaths that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of string
  • IgnoreRegionAccessibilityIds (optional) - elements accessibility_ids that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of string
  • IgnoreRegionAppiumElements (optional) - appium elements that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of appium element object
  • CustomIgnoreRegions (optional) - custom locations that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of ignore_region object
  • IgnoreRegion
    • Description: This class represents a rectangular area on a screen that needs to be ignored for visual diff.
    • Constructor:-
Copy icon Copy snippet
  • Parameters:-
    • Top (int): Top coordinate of the ignore region. Bottom (int): Bottom coordinate of the ignore region.
    • Left (int): Left coordinate of the ignore region. Right (int): Right coordinate of the ignore region.
    • Raises: ArgumentException If top, bottom, left, or right is less than 0 or top is greater than or equal to bottom or left is greater than or equal to right.
    • valid: Ignore region should be within the boundaries of the screen.


Run your test script

Run your tests using percy app:exec.

If you are unable to use the percy app:exec command or prefer to run your tests using IDE run options, you can use the percy app:exec:start and percy app:exec:stop commands. To learn more, visit Run Percy.

Copy icon Copy snippet

This command starts Percy, create a new Percy build, takes snapshots and uploads them to your project, and stops Percy:

Copy icon Copy snippet

Congratulations!

You have successfully created your first build on App Percy. To see the build with snapshots of your application, visit your project in Percy.

When you run another build with visual changes to your application, Percy takes new snapshots. You can then see the comparisons between the two runs on the new build.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Download Copy