Zombie Navigator API (ZAPI): Secure Firefox automation API. Firefox (or equivalent) 38+ is required. Documentation for version 0.6.0 Note: '*' here means 'any type'
Copyright © 2016 Zombie Navigator Developers This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Command-line usage example:
$ ZOMBIE_NAVIGATOR_SCRIPT_PATH=/tmp/script.js firefox
/tmp/script.js:
'use strict';
const {delay, run} = require('zombie/async');
const {console} = require('zombie/zombie');
run(function* () {
const {openWindow, openPrivateWindow} = require('zombie/webbrowser');
try {
let window1 = yield openWindow('about:');
console.log(window1.uri);
yield delay(5); // sleep for 5 seconds
let promise = window1.runScript(uri => {
location.href = uri;
return 42;
}, 'about:buildconfig');
yield window1.waitForReload();
console.log((yield promise), window1.uri);
yield delay(10.5); // sleep for 10.5 seconds
yield window1.close();
console.log('closed');
} catch (e) {
console.error('Error:', e);
}
})
.catch(function (e) {
// uncaught exceptions
});
Asynchronous helper utilities
const {run} = require('zombie/async'); run(function* () { try { let result = yield new Promise(...); } catch (e) { // rejected } throw new Error(); }) .then(function (result) { // generator is finished }) .catch(function (e) { // an error in generator });
const {run} = require('zombie/async');
run(function* () {
try {
let result = yield new Promise(...);
} catch (e) {
// rejected
}
throw new Error();
})
.then(function (result) {
// generator is finished
})
.catch(function (e) {
// an error in generator
});
Open and control Web-browser windows
require('zombie/webbrowser').openPrivateWindow('about:') .then(window => { console.log(window.uri); }) .catch(e => { console.exception(e); // failed });
// writable since 0.4.0
window.uri = 'about:';
window.waitForReload()
.then(...)
let promise = w.runScript(function (arg1, arg2) {
console.log(document.title);
return 'result';
}, 'arg1', 'arg2');
w.screenshot().then(dataURI => {
w.uri = dataURI;
});
Miscellaneous utilities
const {env, getEnvName} = require('zombie/zombie');
env.my_variable; // may be empty ('')
getEnvName('my_variable'); // real variable name
Console API Note that some console output may be suppressed due to the settings
const {console} = require('zombie/zombie'); console.info('Aloha');
Query for Zombie Navigator features and information
const {zombie} = require('zombie/zombie'); zombie.showNotification('Version: ' + zombie.version);