我正在使用Accessibility Plugin + Protractor。
如下所示,我在运行一些冒烟测试后看到一些可访问性错误,我不确定,如果在E2E测试期间在每个网页中实际执行了辅助功能审计。
由于我是新手,请在E2E测试期间导航到新网页后,建议是否有任何方法可以触发辅助功能审核。
e2e-tests $ grunt量角器:websiteSmokeTests --website =“https:// testsite /”
运行“量角器:websiteSmokeTests”(量角器)任务在http://localhost:4444/wd/hub上使用selenium服务器[launcher]运行WebDriver的1个实例
网站主页功能 主页 - 检查无效搜索返回0结果 - 通过 检查网站站长工具 - BingSiteAuth和Google - 通过 WebMaster工具 - 检查Robots.txt - 通过
网站页面反馈功能 检查文章的页面反馈 - 给予否 - 通过
完成28.875秒8次测试,101次断言,0次失败
插件:0(拆解)Chrome A11Y - 此元素不支持ARIA角色,状态和属性如果所有权隐含在DOM Chrome A11Y中,则不应使用Chrome A11Y - aria-owns - 具有ARIA角色的元素必须在正确的范围内Chrome A11Y - 音频元素应具有控件Chrome A11Y - 此元素具有无效的ARIA属性Chrome A11Y - ARIA状态和属性值必须有效
2 elements failed: <div id="cookie-notice" class="notification" aria-describedby="cookieinfo"> <div class="cont ... " id="close-cookie-notification" class="close-notification">Close</button> </div> </div> <div id="decommissioned-site-notice" class="notification strong hidden" aria-describedby="decommissi ... -site-notification"
类=“关闭通知”>关闭
https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_04 Chrome A11Y - Elements with ARIA roles must use a valid, non-abstract ARIA role Chrome A11Y - Controls and media elements should have labels Chrome A11Y - An element's ID must be unique in the DOM Chrome A11Y - (WARNING) These elements are focusable but either invisible or obscured by another element (10 elements failed) Chrome A11Y - The web page should have the content's human language indicated in the markup Chrome A11Y - Images should have an alt attribute Chrome A11Y - (WARNING) The purpose of each link should be clear from the link text (3 elements failed) Chrome A11Y - (WARNING) Text elements should have a reasonable contrast ratio (4 elements failed) Chrome A11Y - role=main should only appear on significant elements Chrome A11Y - Meaningful images should not be used in element backgrounds Chrome A11Y - An element's ID must not be present in more that one aria-owns attribute at any time Chrome A11Y - ARIA attributes which refer to other elements by ID should refer to elements which exist in the DOM 2 elements failed: <div id="cookie-notice" class="notification" aria-describedby="cookieinfo"> <div class="cont ... " id="close-cookie-notification" class="close-notification">Close</button> </div> </div> <div id="decommissioned-site-notice" class="notification strong hidden" aria-describedby="decommissi ... -site-notification"
类=“关闭通知”>关闭
https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_02 Chrome A11Y - This element has an unsupported ARIA attribute 2 elements failed: <div id="cookie-notice" class="notification" aria-describedby="cookieinfo"> <div class="cont ... " id="close-cookie-notification" class="close-notification">Close</button> </div> </div> <div id="decommissioned-site-notice" class="notification strong hidden" aria-describedby="decommissi ... -site-notification"
类=“关闭通知”>关闭
https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_10 Chrome A11Y - Video elements should use <track> elements to provide captions [launcher] 0 instance(s) of WebDriver still running
[launcher] chrome#1 4次测试[launcher]整体失败:4次失败规格[launcher]进程已退出,错误代码为1
测试失败但保持grunt进程活着。
完成,没有错误。
激活后,可访问性插件将与现有的量角器测试一起运行,并会对您的测试命中的每个完整页面进行审核。即使您的测试登陆页面只是为了导航到另一个页面,并且沿途也没有执行任何功能。
旁注:我无法获得ngHint plugin to run on my tests。任何帮助,将不胜感激。
触发审计的方法是编写Accessibility插件可以背负的测试...它不会抓取您的站点以运行审计。
我遇到了同样的问题,所以写了一个量角器 - 可访问性 - 插件的衍生物:protractor-axe-report-plugin。它仅使用ax引擎生成报告,但可以在测试中针对多个页面运行。
如果你愿意自己动手而不使用你遇到困难的辅助功能插件,那么webaccessibility.com有一个免费的实施例“Continuum for Protractor”,它可能是一个很好的起点;您可以使用它将自动化可访问性测试集成到现有的Protractor测试中,或轻松编写新测试。如果你有兴趣,Here's some more information。