node-browser

    0.0.3 • Public • Published

    node-browser Build Status Coverage Status

    wrap webdriver by nodejs promise API, support chrome and phantomjs.

    Usage:

    tnpm i node-browser --save
    
    var Browser = require('@ali/browser');
    var browser = new Browser(option);
    

    option:

    • option.name: default chrome, values: chrome, phantomjs
    • ... // TODO

    Example:

    // get taobao.com page title
    var Browser = require('../../');
    
    var browser = new Browser({
      name: 'chrome'
    });
    
    browser.open('http://taobao.com').then(function () {
    
      var getTitle = function () {
        var title = document.title;
        endCallback(title);
      };
      return browser.injectJs('(' + getTitle.toString() + ')();');
    }).then(function (data) {
      console.log(data.value);
      return browser.close();
    });
    

    API:

    browser.open(url).then();

    open a url

    browser.close().then();

    close browser

    browser.injectJs(script).then();

    inject some javascript

    browser.refresh().then();

    refresh the page

    browser.resize(width, height).then();

    resize

    browser.screenshot().then();

    screenshot,return {string} The screenshot as a base64 encoded PNG.

    Test:

    npm run test
    

    License

    MIT © 2015 sobear

    Install

    npm i node-browser

    DownloadsWeekly Downloads

    44

    Version

    0.0.3

    License

    MIT

    Last publish

    Collaborators

    • sobear