Appium Native C# Tutorial
1. π€ How it works
Applitools SDKs work with existing test frameworks to take screenshots of pages, elements, regions or iframes and upload them along with DOM snapshots to our Eyes server. Our AI then compares them with previous test executions' screenshots (aka Baselines) and reports if there is a bug or not. It's that simple!

1.1 Baseline vs. Checkpoint images
When you first run the test, our A.I. server stores those first set of screenshots as Baseline images. When you run the same test again (and everytime there after), the A.I. server compares the new set of screenshots, aka Checkpoint images, with the corresponding Baseline images and highlights differences in a pink color.

1.2 Marking the test as "Pass" or "Fail"
When the AI compares the baseline and the checkpoint image, if it finds a legitimate difference, it will mark the test as Unresolved. This is because the AI doesn't know if the difference is because of a new feature or a real bug and will wait for you to manually mark it as a Pass/Fail for the 1st time.
If you mark the Unresolved checkpoint image as "Failed", it'll only mark the current test result as Failed.

Note:
To automatically mark the checkpoint as a "Fail" in the future test runs, you need to do the following:
- Annotate at least one of differences as a "bug region"
- Select the "Fail tests" checkbox in the popup window
- Press "Thumbs Up" (not "Thumbs Down") button in the checkpoint image's toolbar (Note: this is counter-intuitive. But what happens is that, we now create a new Baseline along with this bug and "Failed" metadata. So if the same image with the exact bug appears, it'll fail again)
- Press "Save" in the main toolbar
If you mark the Unresolved checkpoint image as a "Pass", then it means that the difference is due to a new feature so we set the new checkpoint image as the new baseline and mark the current test as Pass. Going forward we'll compare any future tests with this new baseline.

Note:
Applitools AI has been trained with 100s of millions of images. It doesn't do pixel-to-pixel comparison as this can lead to a lot of false positives. It instead simulates human eyes that ignore differences that humans can't detect and highlight differences that humans can detect.
ACCURACY: Our A.I.'s current accuracy rate is 99.9999%! Which means for most applications the odds that you'll see false-positives are 1 in a million!
A powerful test results dashboard
We provide a state-of-the-art dashboard that makes it very easy for you to analyze differences, report bugs and much more. For more information on the Applitools dashboard check out these articles.

2. πΌ Analyzing differences
The following Gifs show various tools Applitools provides to easily analyze various differences
Highlight differences between the baseline and checkpoint

Zoom into differences

Toggle between baseline and checkpoint

Show both the baseline and checkpoint side-by-side

3. π Reporting bugs (straight into Jira or Github)
You can select a section of the image and directly file a bug in Jira or Github. No need to manually take screenshots, write steps and explain things! To read more about bug regions check out this article.

4. β Prerequisites
Create a free Applitools account and get your Applitools API KEY
Set the
APPLITOOLS_API_KEY
environment variableMac:
export APPLITOOLS_API_KEY='YOUR_API_KEY'
Windows:
set APPLITOOLS_API_KEY='YOUR_API_KEY'
TIP
- You may skip this step if you want to hard code the API KEY inside the tutorial project's code.
- It's better to store APPLITOOLS_API_KEY in the system variables (in Windows) or in the
~/.bash_profile
(in Mac) so that it is accessible from all Terminal shells
Install Visual Studio from here
Install git from https://git-scm.comβ
TIP
Installing
git
is optional. You need this mainly to clone the demo project from the Github repository. Instead of installinggit
, you can simply download the Zip file from the repo. Further, If you are using Mac OSX, you already havegit
.An iOS or Android Simulator/Device to run the app
Install Appium from here
5.1 π - Run the existing demo app
- Get the code:
- Option 1:
git clone https://github.com/applitools/tutorial-appium-csharp-basic
- Option 2: Download it as a Zip file and unzip it.
- Option 1:
- Import the project into Visual Studio:
- Open Visual Studio from the command line by running something similar to:
open /Applications/Visual\ Studio.app/
rather than double-clicking on it. This approach will load all the environment variables such as APPLITOOLS_API_KEY from the command line shell.
- Open Visual Studio from the command line by running something similar to:
Note
Do not open Visual Studio by double clicking it as it will not load environment variables. If you already have it open, please close it and open it from the Command line.
In Visual Studio, open the
ApplitoolsTutorial
by navigating to the downloaded project viaFile | open
and double click theApplitoolsTutorials.sln
file.Update SDK and Dependencies:
- Right click the Dependencies folder in Visual Studio
- Select Update
Ensure Appium is downloaded and running
Hit Run button in Visual Studio to run the code
5.2 π€ - Add Applitools to an existing project
- Include the SDK as a Nuget Package
- In Visual Studio select Project > Manage Nuget Packages
- Search for Eyes.Appium Package and select the package
- Click "Add Package"
Example Test On Android Simulator
using Applitools.Appium;
using NUnit.Framework;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Enums;
using OpenQA.Selenium.Remote;
using System;
namespace ApplitoolsTutorial
{
[TestFixture]
public class BasicDemo
{
private RemoteWebDriver driver;
private Eyes eyes;
[Test]
public void AndroidTest()
{
// Initialize the eyes SDK (IMPORTANT: make sure your API key is set in the APPLITOOLS_API_KEY env variable).
eyes = new Eyes();
// Set the desired capabilities. If using IOS, change capabilities accordingly
AppiumOptions options = new AppiumOptions();
options.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Samsung Galaxy S9 WQHD GoogleAPI Emulator");
options.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "9.0");
options.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
options.AddAdditionalCapability(MobileCapabilityType.App, "https://applitools.bintray.com/Examples/eyes-hello-world.apk");
options.AddAdditionalCapability("deviceOrientation", "portrait");
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);
// Start visual UI testing.
eyes.Open(driver, "Contacts!", "My first Appium native C# test!");
// Visual UI testing.
eyes.CheckWindow("Contact list!");
// End the test.
eyes.Close();
}
[TearDown]
public void AfterEach()
{
// Close the browser.
driver.Quit();
// If the test was aborted before eyes.close was called, ends the test as aborted.
eyes.AbortIfNotClosed();
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
βοΈ 6. Troubleshooting Common Issues
Forgetting to set your API key (or getting 401 exception):
Not properly loading the API key from the environment variable into your IDE (like Eclipse):
- After setting the APPLITOOLS_API_KEY in the environment variable to hold your Applitools API key, open the IDE from the command line terminal (and not from the IDE directly). On Mac, itβd look like this: Open a Terminal and then type:
open ~/Applications/Eclipse.app
. This will load Eclipse with all the environment variables.
- After setting the APPLITOOLS_API_KEY in the environment variable to hold your Applitools API key, open the IDE from the command line terminal (and not from the IDE directly). On Mac, itβd look like this: Open a Terminal and then type:
Trying to run the test but nothing happens:
- Check if the APPLITOOLS_API_KEY is null
Debug logs:
- See this article to enable debug logs to help file support ticket
Failed to connect to Appium:
- Ensure you have Appium downloaded and running
Resources
Terms & Conditions Privacy Policy GDPRΒ© 2020 Applitools. All rights reserved.