Xping SDK is a free and open-source .NET library written in C# to help automate Web Application or Web API testing.
Report Bug
·
Request Feature
Table of Contents
Xping SDK provides a comprehensive set of tools to simplify writing automated tests for Web Applications and Web APIs, as well as troubleshooting issues during testing. The library offers features to verify the correct functionality of web applications, such as ensuring the correct data is displayed on a page or the appropriate error messages appear when an error occurs.
In addition to these core features, Xping SDK leverages AI-powered testing and live site monitoring techniques to enhance test reliability and performance. This ensures that your web applications are not only functioning correctly but are also monitored for real-time performance and availability.
The library, named Xping, stands for eXternal Pings and is used to verify the availability of a server and monitor its content.
For more information about the library, including documentation and examples, visit the official website xping.io.
The library is distributed as a NuGet packages, which can be installed using the .NET CLI command dotnet add package
. Here are the steps to get started:
-
Open a command prompt or terminal window.
-
Navigate to the directory where your project is located.
-
Run the following command to install the Xping NuGet package:
dotnet add package Xping.Sdk
-
Once the package is installed, you can start using the Xping library in your project.
using Xping.Sdk.Core.DependencyInjection;
Host.CreateDefaultBuilder()
.ConfigureServices(services =>
{
.AddHttpClientFactory()
.AddTestAgent(agent =>
{
agent.UploadToken = "--- Your Dashboard Upload Token ---";
agent.ApiKey = "--- Your Dashboard API Key ---"; // For authentication with Xping services
agent.UseDnsLookup()
.UseIPAddressAccessibilityCheck()
.UseHttpClient()
.UseHttpValidation(response =>
{
Expect(response)
.ToHaveSuccessStatusCode()
.ToHaveResponseTimeLessThan(TimeSpan.FromMilliseconds(MaxResponseTimeMs))
.ToHaveHeaderWithValue(HeaderNames.Server, "ServerName");
})
.UseHtmlValidation(html =>
{
Expect(html).ToHaveTitle("Home page");
});
});
});
using Xping.Sdk.Core;
using Xping.Sdk.Core.Session;
var testAgent = _serviceProvider.GetRequiredService<TestAgent>();
TestSession session = await testAgent.RunAsync(new Uri("www.demoblaze.com"));
You can also integrate it with your preferred testing framework, such as NUnit, as shown below:
[TestFixtureSource(typeof(XpingTestFixture))]
public class HomePageTests(TestAgent testAgent) : XpingAssertions
{
[OneTimeSetUp]
public void OneTimeSetUp()
{
testAgent.UploadToken = "--- Your Dashboard Upload Token ---";
testAgent.ApiKey = "--- Your Dashboard API Key ---"; // For authentication with Xping services
}
[Test]
public async Task VerifyHomePageTitle()
{
testAgent.UseBrowserClient()
.UsePageValidation(async page =>
{
await Expect(page).ToHaveTitleAsync("STORE");
});
await using TestSession session = await testAgent.RunAsync(new Uri("https://demoblaze.com"));
Assert.That(session.IsValid, Is.True, session.Failures.FirstOrDefault()?.ErrorMessage);
}
That’s it! You’re now ready to start automating your web application tests and monitoring your server’s content using Xping.
The samples
folder in this repository contains various examples of how to use Xping SDK for your testing needs. For a comprehensive guide on how to install, configure, and customize Xping SDK, please refer to the docs.
Xping SDK supports authentication with Xping services using an API key. This key is used to authenticate requests when uploading test results to your dashboard.
You can set the API key in two ways:
Method 1: Explicitly in code
services.AddTestAgent(agent =>
{
agent.ApiKey = "your-api-key-here";
});
Method 2: Using environment variable (recommended for CI/CD)
export XPING_API_KEY="your-api-key-here"
When using environment variables, you don't need to set the API key explicitly in your code. The SDK will automatically read the value from the XPING_API_KEY
environment variable.
Note: If you set the API key explicitly in code, it will take precedence over the environment variable.
We use Milestones to communicate upcoming changes in Xping SDK:
-
Working Set refers to the features that are currently being actively worked on. While not all of these features will be committed in the next release, they do reflect the top priorities of the maintainers for the upcoming period.
-
Backlog is a set of feature candidates for some future releases, but are not being actively worked on.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
file for more information.