Skip to content

Commit

Permalink
test script for axe
Browse files Browse the repository at this point in the history
  • Loading branch information
mpnkhan committed Sep 1, 2021
1 parent a906e4b commit c845dc9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 4 deletions.
4 changes: 0 additions & 4 deletions ptest.js

This file was deleted.

50 changes: 50 additions & 0 deletions ptest1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

var path = require('path')
var childProcess = require('child_process')
var phantomjs = require('phantomjs-prebuilt')
var binPath = phantomjs.path


var source = '<!DOCTYPE html><html lang="en"><meta charset="utf-8"><head><title>Home - PayPal Accessibility Tool</title></head><body>'
+ '<div>Test div : <input> </div>'
+ '</body></html>';

var childArgs = [
path.join(__dirname, 'ptest2.js'),
source
]

childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
// handle results
console.log('Error', JSON.stringify(stderr));
console.log('Output', JSON.stringify(stdout));
})




/*
if ( typeof(phantom) !== "undefined" ) {
var page = require('webpage').create();
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.onAlert = function(msg) {
console.log(msg);
};
console.log("* Script running in the Phantom context.");
console.log("* Script will 'inject' itself in a page...");
page.open("about:blank", function(status) {
if ( status === "success" ) {
console.log(page.injectJs("injectme.js") ? "... done injecting itself!" : "... fail! Check the $PWD?!");
}
phantom.exit();
});
} else {
console.log("* Script running in the Page context.");
}
*/
24 changes: 24 additions & 0 deletions ptest2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var args = require('system').args;
var source= args[1];
var page = require('webpage').create();
var PATH_TO_AXE = './src/axe/axe.js';

page.settings.webSecurityEnabled = false;
page.content = source;

page.injectJs(PATH_TO_AXE);
page.framesName.forEach(function (name) {
page.switchToFrame(name);
page.injectJs(PATH_TO_AXE);
});
page.switchToMainFrame();
page.evaluate(function () {
axe.run(document.body, function(err, results) {
window.callPhantom(results);
});
});

page.onCallback = function (results) {
console.log(JSON.stringify(results))
phantom.exit();
}

0 comments on commit c845dc9

Please sign in to comment.