paypal / AATT

Automated Accessibility Testing Tool
BSD 3-Clause "New" or "Revised" License
602 stars 106 forks source link

How to use AATT with my own node.js/selenium based framework or with webdriver.io #53

Closed amiya-pattnaik closed 3 years ago

amiya-pattnaik commented 5 years ago

Hi Team, I saw this tool and I am impressed on this. Just few questions

  1. How can I integrate this tool with my own node.js/selenium based framework (which used Jasmine or Mocha)
  2. Can I use this tool with webdriver.io ?
  3. Where can I provide the URL to start the testing etc. And also does it require always navigate to the specific page through selenium scripts. I saw some commands like nomo.drover.url() commands etc.

Thanks in advance.

mpnkhan commented 5 years ago

AATT will serve a API within your environment to evaluate. You need to use the API end point "https://your_nodejs_accessibility_server/evaluate" .

Example with webdrver.io

//scan
function scan(source) {
    if (browser.sessionId){
            console.log('S O U R C E', source);
            var body = {
              'source': '<input>',  //set the source html here
              'engine' : 'axe',
              'output': 'json'
            },
            options = {
              'headers': {
                'Content-Type': 'application/json'
              },
              'url': 'http://localhost:3000/evaluate',
              'method': 'POST',
              'body': body,
              'json': true,
              'rejectUnauthorized': false
            };

                return new Promise(function(resolve, reject) {
                    let retStr ='';                    
                    request(options, function (err, response, responseBody) {
                        if (err) {
                            reject(err);
                        }
                        if (err || response.statusCode !== 200) {
                          reject('Error is ' + err + ' Response code is ' + (response && response.statusCode));
                        }
                        else{
                            // retStr = processResultsAxe(responseBody);
                            retStr = responseBody;
                            resolve(retStr);
                        }               
                    });

                }) //Promise            

    }
    else{
        reject('Session Id was not defined');
    }
}

Yes you need to navigate.

amiya-pattnaik commented 5 years ago

Thanks Nawaz for the updates. Just help me with below silly question.

  1. API endpoint "https://your_nodejs_accessibility_server/evaluate" . What does it mean? Do you mean that the actual endpoint of my application? for example, if I am testing the login functionality of my application then should I give the login endpoint URL here?

  2. 'url': 'http://localhost:3000/evaluate' in Options. What id does and what is its significance?

  3. in the function scan(source) , what should be the source? will it the page URL?

  4. Wher can I navigate to a different page ? for example, in my webdriver.io with mocha spec, I have test cases in it() block where I navigate to the page using selenium. in that case, how can I use AATT?

Please advise. Thanks in advance. Amiya

mpnkhan commented 5 years ago
  1. API end point is http://localhost:3000/evaluate. That is machine where your AATT runs. You could also install aatt as node module and use it, see readme.
  2. Options also defined in Readme. you can choose engine, some engine specific parameters.
  3. source should be page source which want to test
  4. Just call evaluate or scan method(shown above) in you test case where you thing your html source is ready for testing.
amiya-pattnaik commented 5 years ago

Thanks, Nawaz for the updates. Its now clear to me. I have to start the express server locally in one instance and in another instance I have start my automation test. Now tests are running and I could see that How can I see the rules violations in the console (DEBUG=AATT* http_port=3000 node app.js).

I need your advice on how can I get the results in an .html file or the snapshot of the page with highlighted fields etc Please advise. I appreciate your help. Thanks