2 回答
TA贡献1895条经验 获得超7个赞
对于问题中的任何行的答案,我使用的是带有 WAVE 扩展名的那些行,这就是问题所在。
我没有尝试过用Wave实现这一点的方法。它不适用于Wave只会为您提供错误的快照。
从快照中,您将无法获得诸如错误或缺陷类型之类的想法。我建议不要为辅助功能测试使用 WAVE 扩展。而不是使用工具“ Globant.Selenium.Axe ”。使用Nuget 包管理器安装插件
这是Chrome 扩展程序的链接。
这是在文本文件中记录错误的代码:
//If file does not exists, Create a new file and log the result.
if (!File.Exists(accessiblityTestFileLocation))
{
File.Create(accessiblityTestFileLocation).Dispose();
LogResult ();
}
//If file exists, Log the result into file.
else if (File.Exists(accessiblityTestFileLocation))
{
LogResult ();
}
日志结果函数:
public void LogResult ()
{
using (StreamWriter sw = new StreamWriter(accessiblityTestFileLocation))
{
foreach (var path in appInfo.Pages)
{
var navigateUrl = new Uri(baseUrl, path.Path);
driver.Navigate().GoToUrl(navigateUrl);
driverService.driver.Manage().Window.Maximize();
AxeResult results = driver.Analyze();
//Format the results, And write them in the text file.
if (results.Passes.Length > 0)
{
//Format the text as per your need, This text will be entered into the Text file.
sw.WriteLine("\n");
sw.WriteLine(path.Title);
sw.WriteLine("===========================");
sw.WriteLine("\n");
foreach (var passCase in results.Passes)
{
sw.WriteLine("Id: " + passCase.Id);
sw.WriteLine("Description: " + passCase.Description);
sw.WriteLine("Impact: " + "Normal");
sw.WriteLine("Help: " + passCase.Help);
sw.WriteLine("HelpURL: " + passCase.HelpUrl);
foreach (var node in passCase.Nodes)
{
sw.WriteLine(node.Html);
sw.WriteLine("\n");
}
}
}
//Format the results based on the result type, And write them in the text file.
if (results.Violations.Length > 0)
{
foreach (var violation in results.Violations)
{
//Write the accessibility test for the selected Attributes provided by the Axecore.
sw.WriteLine("Id: " + violation.Id);
sw.WriteLine("Description: " + violation.Description);
sw.WriteLine("Impact: " + violation.Impact);
sw.WriteLine("Help: " + violation.Help);
sw.WriteLine("HelpURL: " + violation.HelpUrl);
foreach (var node in violation.Nodes)
{
sw.WriteLine(node.Html);
sw.WriteLine("\n");
}
}
}
}
}
}
TA贡献1757条经验 获得超7个赞
2件事。他们已移动链接以启用 Chrome 插件的快捷键。您甚至可以通过手动切换其中任何一个来查看这一点。该选项仍然可用@ chrome://extensions,但它不再位于页面底部,而是用户 id=menuButton。
我还认为,即使您启用了该选项,您在将 CTRL+m 发送到浏览器时也会遇到问题。
- 2 回答
- 0 关注
- 128 浏览
添加回答
举报