electrun
v0.0.3
Published
run on electron
Downloads
6
Maintainers
Readme
electrun
browser automation library. inspired by nightmare
install
npm install --save electrun
example
npm install -g babel@5
babel-node example.js
example.js
import Electrun from 'electrun';
async function main() {
let electrun = new Electrun();
electrun.process.stdout.pipe(process.stdout);
electrun.process.stderr.pipe(process.stderr);
let w = await electrun.open({ width: 1024, height: 768, show: true });
await w.goto('about:blank');
await w.devTool(true);
await w.eval(`process.stdout.write('hello, electrun!\\n')`);
await w.eval(`console.log('this will presented on devtool')`);
await w.wait(3000);
w.goto('http://google.com/');
await w.wait('#lst-ib');
// following code is todo
await w.val('#lst-ib', 'electron');
await w.submit('form');
w.once('did-finish-load', async () => {
await w.saveScreenshot('./electron.png');
});
}
main().catch(err => console.error(err && err.stack || err));
api
Electrun
open([browserWindowOptions]) -> Promise<BrowserWindow>
: open and returns browser window (options)kill() -> void
: kill electron process
BrowserWindow
close() -> Promise
: close browser windowauth(username, password) -> Promise
: set user info for passing basic authenticationgoto(urlString) -> Promise
: goto urlwait(msOrSelector) -> Promise
: wait till selected element is presenteval(code) -> Promise<JsonValue>
: eval javascript code and return resultclick(selector) -> Promise
mousedown(selector) -> Promise
reload() -> Promise
: reload pagef5() -> Promise
: same asreload
devTool() -> Promise
: toggle developer tooldevTool(true) -> Promise
: open developer tooldevTool(false) -> Promise
: close developer toolf12() -> Promise
: same asdevTool
todo
val(selector) -> Promise<JsonValue>
val(selector, value) -> Promise
screenshot([rect]) -> Promise<Buffer>
: returns screenshot as png buffer (rect)saveScreenshot(savePath[, rect]) -> Promise
: save screenshot as pngpdf([options]) -> Promise<Buffer>
: (options)savePdf(savePath[, options]) -> Promise