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 關注
- 155 瀏覽
添加回答
舉報