PercyIO.Appium
3.0.0
See the version list below for details.
dotnet add package PercyIO.Appium --version 3.0.0
NuGet\Install-Package PercyIO.Appium -Version 3.0.0
<PackageReference Include="PercyIO.Appium" Version="3.0.0" />
paket add PercyIO.Appium --version 3.0.0
#r "nuget: PercyIO.Appium, 3.0.0"
// Install PercyIO.Appium as a Cake Addin #addin nuget:?package=PercyIO.Appium&version=3.0.0 // Install PercyIO.Appium as a Cake Tool #tool nuget:?package=PercyIO.Appium&version=3.0.0
percy-appium-dotnet
Percy visual testing for .NET Selenium.
NuGet
Dependencies:
- Newtonsoft.Json Version >= 13.0.1
- Castle.Core Version >= 4.3.1
- Microsoft.CSharp Version >= 4.7.0
Note: This package is tested against .netstandard 2.0 should be compatible with and standard that is superset of this.
Installation
npm install @percy/cli
(requires Node 14+):
$ npm install --save-dev @percy/cli
Install the PercyIO.Appium package (for example, with .NET CLI):
$ dotnet add package PercyIO.Appium
Usage
This is an example test using the Percy.Snapshot
method.
// ... other test code
// import
using PercyIO.Appium;
class Program
{
private static AppPercy percy;
static void Main(string[] args)
{
AppiumOptions capabilities = new AppiumOptions();
// Add caps here
AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(
new Uri("http://hub-cloud.browserstack.com/wd/hub"), capabilities);
// take a snapshot
appPercy = new AppPercy(driver);
appPercy.Screenshot("dotnet snaphot-1", null);
// quit driver
driver.quit();
}
}
Running the above normally will result in the following log:
[percy] Percy is not running, disabling snapshots
When running with percy exec
, and your project's
PERCY_TOKEN
, a new Percy build will be created and snapshots will be uploaded to your project.
$ export PERCY_TOKEN=[your-project-token]
$ percy app:exec -- [your dotnet test command]
[percy] Percy has started!
[percy] Created build #1: https://percy.io/[your-project]
[percy] Screenshot taken "dotnet snaphot-1"
[percy] Stopping percy...
[percy] Finalized build #1: https://percy.io/[your-project]
[percy] Done!
Configuration
The screenshot method arguments:
percy.screenshot(name, fullScreen)
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 screenoptions
- Optional screenshot params: UseScreenshotOptions
to set following params to overrideDeviceName
- Device name on which screenshot is takenStatusBarHeight
- Height of status bar for the deviceNavBarHeight
- Height of navigation bar for the deviceOrientation
- Orientation of the applicationFullPage
: true/false. [Experimental] only supported on App Automate driver sessions [ needs @percy/cli 1.20.2+ ]ScreenLengths
: int [Experimental] max screen lengths for fullPage [ needs @percy/cli 1.20.2+ ]ScrollableXpath
(optional) - [Experimental] scrollable element xpath for fullpage [ needs @percy/cli 1.20.2+ ]; stringScrollableId
(optional) - [Experimental] scrollable element accessibility id for fullpage [ needs @percy/cli 1.20.2+ ]; stringIgnoreRegionXpaths
(optional) - elements xpaths that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of stringIgnoreRegionAccessibilityIds
(optional) - elements accessibility_ids that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of stringIgnoreRegionAppiumElements
(optional) - appium elements that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of appium element objectCustomIgnoreRegions
(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:-
var ignoreRegion = new IgnoreRegion(); ignoreRegion.Top = top; ignoreRegion.Bottom = bottom; ignoreRegion.Left = left; ignoreRegion.Right = right;
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.
Running with Hybrid Apps
For a hybrid app, we need to switch to native context before taking screenshot.
- Add a helper method similar to following for say flutter based hybrid app:
public void PercyScreenshotFlutter(AppPercy appPercy, AndroidDriver<AndroidElement> driver, String name, ScreenshotOptions options) {
// switch to native context
driver.Context = "NATIVE_APP";
appPercy.Screenshot(name, options);
// switch back to flutter context
driver.Context = "FLUTTER";
}
- Call PercyScreenshotFlutter helper function when you want to take screenshot.
PercyScreenshotFlutter(appPercy, driver, name, options);
Note:
For other hybrid apps the
driver.Context = "FLUTTER";
would change to context that it uses like say WEBVIEW etc.
Migrating Config
If you have a previous Percy configuration file, migrate it to the newest version with the
config:migrate
command:
$ percy config:migrate
Running Percy on Automate
percyScreenshot(driver, name, options)
[ needs @percy/cli 1.27.0-beta.0+ ];
This is an example test using the Percy.Screenshot
method.
// ... other test code
// import
using PercyIO.Appium;
class Program
{
static void Main(string[] args)
{
// Add caps here
RemoteWebDriver driver = new RemoteWebDriver(
new Uri("https://hub-cloud.browserstack.com/wd/hub"),capabilities);
// take a snapshot
PercyOnAutomate Percy = new PercyOnAutomate(driver);
// navigate to webpage
driver.Navigate().GoToUrl("https://www.percy.io");
Percy.Screenshot("dotnet screenshot-1");
// quit driver
driver.quit();
}
}
driver
(required) - A appium driver instancename
(required) - The screenshot name; must be unique to each screenshotoptions
(optional) - There are various options supported by percy_screenshot to server further functionality.freezeAnimation
- Boolean value by default it falls back tofalse
, you can passtrue
and percy will freeze image based animations.percyCSS
- Custom CSS to be added to DOM before the screenshot being taken. Note: This gets removed once the screenshot is taken.ignoreRegionXpaths
- elements in the DOM can be ignored using xpathignoreRegionSelectors
- elements in the DOM can be ignored using selectors.ignoreRegionAppiumElements
- elements can be ignored using appium_elements.customIgnoreRegions
- elements can be ignored using custom boundaries- IgnoreRegion:-
Description: This class represents a rectangular area on a screen that needs to be ignored for visual diff.
Constructor:
init(self, top, bottom, left, right)
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:ValueError: 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.
- IgnoreRegion:-
Creating Percy on automate build
Note: Automate Percy Token starts with auto
keyword. The command can be triggered using exec
keyword.
$ export PERCY_TOKEN=[your-project-token]
$ percy exec -- [python test command]
[percy] Percy has started!
[percy] [Python example] : Starting automate screenshot ...
[percy] Screenshot taken "Python example"
[percy] Stopping percy...
[percy] Finalized build #1: https://percy.io/[your-project]
[percy] Done!
Refer to docs here: Percy on Automate
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Castle.Core (>= 4.3.1)
- Microsoft.CSharp (>= 4.7.0)
- Newtonsoft.Json (>= 13.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on PercyIO.Appium:
Package | Downloads |
---|---|
BrowserStack.TestAdapter
VS TestAdapter for integrating selenium tests with BrowserStack |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.8 | 434 | 10/28/2024 |
3.0.7 | 2,146 | 4/30/2024 |
3.0.6 | 306 | 4/16/2024 |
3.0.5 | 280 | 3/28/2024 |
3.0.4 | 494 | 2/19/2024 |
3.0.3 | 265 | 2/6/2024 |
3.0.3-beta.0 | 65 | 2/1/2024 |
3.0.2 | 37,767 | 10/27/2023 |
3.0.1 | 472 | 9/11/2023 |
3.0.1-beta.2 | 95 | 8/10/2023 |
3.0.1-beta.1 | 88 | 7/26/2023 |
3.0.1-beta.0 | 88 | 7/19/2023 |
3.0.1-alpha.1 | 83 | 10/26/2023 |
3.0.0 | 167 | 9/6/2023 |
3.0.0-beta.0 | 77 | 7/14/2023 |
2.1.4 | 45,928 | 7/6/2023 |
2.1.3 | 498 | 6/22/2023 |
2.1.2 | 223 | 6/13/2023 |
2.1.1 | 223 | 6/8/2023 |
2.1.0 | 1,045 | 6/8/2023 |
2.0.1 | 208 | 5/29/2023 |
2.0.0 | 207 | 5/19/2023 |
1.2.3 | 1,015 | 4/21/2023 |
1.2.2 | 308 | 4/18/2023 |
1.2.1 | 224 | 4/12/2023 |