Hi
I have the following code. However i would like to return validationresults for rule 1 (I have HTML which should fail 1.4.4)
I would like to se examples on how to create the validator, so that these tests are executed.
// code start
using Aspose.Html;
using Aspose.Html.Accessibility;
using ValidationResult = Aspose.Html.Accessibility.Results.ValidationResult;
var webAccessibility = new WebAccessibility();
// Initialize an object of HTMLDocument class
using (var document = new Aspose.Html.HTMLDocument(“c:\data2\123.html”))
{
Principle principle = webAccessibility.Rules.GetPrinciple(“1”);
Guideline guideline = principle.GetGuideline(“1.4”);
if (guideline != null)
{
Console.WriteLine(“{0}:{1}”, guideline.Code, guideline.Description, guideline);
foreach (var crit in guideline.GetCriterions())
{
Console.WriteLine(“{0}:{1}”, crit.Code, crit.Description);
}
}
var validator = webAccessibility.CreateValidator(builder => builder.AllLevels().AllTechnologies());
// Check the document
ValidationResult validationResult = validator.Validate(document);
// Checking for success
//if (!validationResult.Success)
{
// Get a list of Details
foreach (var detail in validationResult.Details)
{
Console.WriteLine("{0}:{1} = {2}", detail.Rule.Code, detail.Rule.Description, detail.Success);
if (!detail.Success)
{
foreach (var err in detail.Errors)
{
HTMLElement elem = (HTMLElement)err.Error.Target.Item;
Console.WriteLine("{0} ---- {1}", err.Error.ErrorMessage, elem.OuterHTML);
}
}
}
}
}
// code end
123.zip (311 Bytes)
I have used the following online service to test my html
https://websiteaccessibilitychecker.com/checker/index.php
And this site shows that it fails on criteria 1.4.4
Could someone correct my code or provide an example on how to set it up correctly.
My final goal is to create a complete list of errors in a lager HTML document.
@ljensen12
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): HTMLNET-5131
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@ljensen12
We have investigated the ticket.
- In order to return test results for a single rule, for example Guideline “1.4”, you can use one of the options below:
var validator = webAccessibility.CreateValidator(guideline, builder => builder.AllLevels().AllTechnologies());
or
var validator = webAccessibility.CreateValidator(guideline, ValidationBuilder.All);
or
var validator = webAccessibility.CreateValidator(guideline);
- Accessibility compliance testing is conducted in accordance with WSAG 2.0 guidelines. This rule is not listed in the list of rules in Criterion 1.4.4.
The accessibility test you specified above should not be construed as required to comply with the proposed WCAG2.
- To use the full list of rules in an HTML document, you must use the code with a validator:
var webAccessibility = new WebAccessibility();
using (var document = new Aspose.Html.HTMLDocument(Path.Combine(Directory.GetCurrentDirectory(), @"data2\123.html")))
{
var validator = webAccessibility.CreateValidator();
/*
or
var validator = webAccessibility.CreateValidator(ValidationBuilder.All);
or
var validator = webAccessibility.CreateValidator(builder => builder.AllLevels().AllTechnologies());
*/
// Check the document
var validationResult = validator.Validate(document);
// Get a list of Details
foreach (var detail in validationResult.Details)
{
Console.WriteLine("{0}:{1} = {2}", detail.Rule.Code, detail.Rule.Description, detail.Success);
if (!detail.Success)
{
foreach (var err in detail.Errors)
{
Console.WriteLine("*** {0}:{1}", err.Rule.Code, err.Rule.Description);
HTMLElement elem = (HTMLElement)err.Error.Target.Item;
Console.WriteLine(" {0} ---- {1}", err.Error.ErrorMessage, elem.OuterHTML);
}
Console.WriteLine();
}
}
}
The full result of the validate for this document is shown in screenshot.
123result.png (23.0 KB)
But in evaluation mode there is a limit on the number of rules that can be checked. The result of checking 123.html with the evaluated mode will be like this:
123result_evalmode.png (4.1 KB)
In order to gain access to the full list of rules, you can request a temporary license.