Testing native mobile apps in C# using Appium | Applitools Documentation
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
ApplitoolsTutorialby navigating to the downloaded project viaFile | openand double click theApplitoolsTutorials.slnfile.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
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.
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");
options.AddAdditionalCapability("username", Environment.GetEnvironmentVariable("SAUCE_USERNAME"));
options.AddAdditionalCapability("accesskey", Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY"));
options.AddAdditionalCapability("name", "Android Demo");
driver = new RemoteWebDriver(new Uri("http://ondemand.saucelabs.com/wd/hub"), options);
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();
}
}
}
Having Trouble?
Don't suffer in silence! Let us help you. Please reach out to us to get your project working.
Taking the next steps with Applitools Eyes
Congratulations on completing this quickstart! There's still so much to learn about visual testing with Applitools, but you're off to a great start.