Continuum for C#
Loading...
Searching...
No Matches
Continuum for C

Compatibility

  • The C# SDK is compatible with .NET 6.0 and up
  • Browser support was tested with Chrome, Firefox and the Chromium-based Edge, and may work with other web drivers supported by the Selenium WebDriver SDK

Dependencies

  • .NET 6.0+
  • The only required library is Selenium WebDriver (nuget OpenQA.Selenium)

Getting Started

Start by adding a reference to the library LevelAccess.Continuum.dll in your test project and importing the SDK namespace - this library file can be found in the lib folder.

Definition AccessibilityConcern.cs:7

You will then need to go through 3 steps to get up and running. These steps are:

  1. Initialize Continuum with a configuration file
  2. Initialize a supported WebDriver of your choice
  3. Set up Continuum with a reference to your WebDriver

Keep reading below for a walkthrough of this process.

1. Initialize Continuum

First, create an instance of Continuum and pass the path to your configuration file as an argument. The path can be relative to the test project executable file, or an absolute path.

var continuum = new Continuum("./Resources/continuum.json");
This class encapsulates all of the helper functionality Access Continuum offers for running Access En...
Definition Continuum.cs:20

You should use the same instance of Continuum across multiple tests, so make sure to initialize it in your testing framework setup method that runs before all tests.

Second, make sure to update your configuration file with your AMP access token and any other desired preferences. Here's what the continuum.json file should look like:

{
"ampApiToken": null,
"ampInstanceUrl": "https://amp.levelaccess.net",
"defaultStandardIds": [
610, /* WCAG 2.0 Level A */
611, /* WCAG 2.0 Level AA */
612, /* WCAG 2.0 Level AAA */
1387, /* WCAG 2.1 Level A */
1388, /* WCAG 2.1 Level AA */
1389, /* WCAG 2.1 Level AAA */
1140, /* Section 508 and 255 (Revised 2017) */
1471 /* WCAG 2.0 Level A & AA Baseline */
],
"proxy": {
"password": null,
"username": null,
"port": null,
"host": null
},
"accessibilityConcerns": {
"format": "amp",
"includePotentialConcerns": false
},
"accessEngineType": "${accessEngineType}"
}

2. Initialize WebDriver

This step can be done in a variety of ways and is independent of the Continuum SDK. We're providing the instructions below for your convenience, but please check the official documentation of Selenium WebDriver or WebDriverManager if you need more information.

All of the code snippets below reference the ChromeDriver as an example, but you can also use other supported Web Drivers. See the compatibility notes at the top for more details.

2.1. Chrome driver is already installed on the system PATH

If you already have a Chrome driver installed in your environment and available on the system PATH, this step can be as simple as this:

var driver = new ChromeDriver();

2.2. Automatically download a matching version of the Chrome driver

If you prefer to make your test suite automatically download a matching version of the Chrome driver prior to the setup, this is the minimal implementation that you could use:

var driverManager = new DriverManager();
driverManager.SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);
var driver = new ChromeDriver();

2.3. Download the Chrome version behind a proxy

The DriverManager library accepts an instance of WebProxy with the method below:

// TODO: set your proxy configuration under your instance of WebProxy
var proxy = new WebProxy();
// reassign your driver manager to a new one with your proxy settings
driverManager = driverManager.WithProxy(proxy);

See below a complete example of how you could configure an instance of WebProxy:

{
var proxy = new WebProxy()
{
Address = new Uri($"http://{Configuration.ProxyConfiguration.Host}:{Configuration.ProxyConfiguration.Port}"),
BypassProxyOnLocal = true
};
{
proxy.UseDefaultCredentials = false;
proxy.Credentials = new NetworkCredential(
);
}
driverManager = driverManager.WithProxy(proxy);
}
string Password
Gets the value for the 'password' attribute of the the 'proxy' object defined in continuum....
Definition Configuration.cs:142
string Host
Gets the value for the 'host' attribute of the the 'proxy' object defined in continuum....
Definition Configuration.cs:149
string Username
Gets the value for the 'username' attribute of the the 'proxy' object defined in continuum....
Definition Configuration.cs:135
This class encapsulates all Continuum configuration defined in the user-editable continuum....
Definition Configuration.cs:16
static Proxy ProxyConfiguration
Gets the proxy-specific configuration in Continuum represented by the 'proxy' object defined in conti...
Definition Configuration.cs:63

Check more details on the following documentation:

3. Set up Continuum + WebDriver

It's time to connect the two parts together. You have initialized Continuum and a WebDriver. Now, call the SetUp method of Continuum and pass your WebDriver instance as an argument:

continuum.SetUp(_driver);

You can run this method as many times as you want during the lifecycle of an instance of Continuum. Whenever you need to create a new instance of your WebDriver, please remember to re-execute this method with the new WebDriver instance.

This step is very important to allow Continuum to inject the accessibility scanner in your WebDriver instance whenever it's needed. You can use the same WebDriver instance for as long as you want, but anytime you need to recreate it, make sure to update it on your Continuum instance.

Usage

After following the steps above you finally have the Continuum SDK ready to use.

Once you've navigated to the page you'd like to test, invoke the appropriate Continuum method (all of which execute synchronously). For example, to run all available accessibility tests against the entirety of the current page:

driver.Navigate().GoToUrl("https://www.google.com");
var accessibilityConcerns = continuum.RunAllTests();

You can then do whatever you like with any accessibility concerns returned, like print them out to the console, filter them for only the ones you're interested in, etc.

For AMP users, check out our documentation for the AccessibilityConcern class for a complete list of what's returned for each accessibility concern.

Other Continuum methods are available that allow you to only run particular tests or test against specific best practices. Continuum also allows you to only test a particular part of a page rather than the entire page. All of these methods are detailed in our documentation for the Continuum class.

You have the power!

Support

Questions can be emailed to Level Access support at suppo.nosp@m.rt@l.nosp@m.evela.nosp@m.cces.nosp@m.s.com.