-
Notifications
You must be signed in to change notification settings - Fork 106
/
ptest1.js
50 lines (38 loc) · 1.39 KB
/
ptest1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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.");
}
*/