Report accessibility plugin results

2019-05-21 09:07发布

问题:

The protractor.conf file is configured to report the jasmine test results in junit format according to https://github.com/larrymyers/jasmine-reporters#protractor

// An example configuration file.
// https://raw.github.com/angular/protractor/master/example/conf.js



exports.config = {
    // The address of a running selenium server.
 //   seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.41.0.jar', // Make use you check the version in the folder
    //seleniumAddress: 'http://localhost:4444/wd/hub',
    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome'
    },
    framework: "jasmine2",
    onPrepare: function() {
        var jasmineReporters = require('jasmine-reporters');
        jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
            consolidateAll: true,
            filePrefix: 'xmloutput',
            savePath: 'testresults'
        }));
    },
    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    },
    plugins: [{
        chromeA11YDevTools: true,
        path: 'node_modules/protractor/plugins/accessibility'
    }]
};

Unfortunately it does not report the results from the accessibility plugin.

In the terminal i see:

   Pass:  Chrome A11Y - Audio elements should have controls 
     Pass:  Chrome A11Y - ARIA state and property values must be valid 
     Pass:  Chrome A11Y - Elements with ARIA roles must use a valid, non-abstract ARIA role 
     Fail:  Chrome A11Y - Controls and media elements should have labels 

            2 elements failed:
            <input type="checkbox" ng-model="todo.done" class="ng-pristine ng-untouched ng-valid">
            <input type="checkbox" ng-model="todo.done" class="ng-pristine ng-untouched ng-valid">

            https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#-ax_text_01--controls-and-media-elements-should-have-labels

How may this be achieved?

回答1:

This is not possible with the plugin framework. The problem is that plugins are agnostic to the test framework being used, so they do not emit test results in a way specific to jasmine-reporters.

You can get all test and plugin results in JSON format using resultJsonOutputFile in the config. I'd suggest doing that, and then processing it in any way you need.