How to use the zombie.visit function in zombie

To help you get started, we’ve selected a few zombie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trevorquinn / econstats / server.js View on Github external
var retrieveUnemployment = function(callback) {
    // Screen scrape BLS web page for latest unemployment information
    zombie.visit("http://data.bls.gov/timeseries/LNS14000000", function(err,
            browser, status) {
        var unemploymentData = [];

        // Grab the unemployment table
        var ths = browser.querySelectorAll("table.regular-data tbody th");
        for ( var i = 0; i < ths.length; i++) {
            var unemploymentEntry = {};

            // Grab each row header and use it to set the year
            var th = ths.item(i);
            var year = th.innerHTML.trim();

            // Grab each cell in the row and use it to set the month and
            // unemployment rate
            var tds = th.parentNode.getElementsByTagName("td");
            for ( var j = 0; j < tds.length && j < 12; j++) {
github trevorquinn / econstats / server.js View on Github external
var retrieveEarnings = function(callback) {
    // Screen scrape BLS web page for latest unemployment information
    zombie.visit("http://data.bls.gov/cgi-bin/srgate", function(err,
            browser, status) {
        var earningsData = [];

        // Fill in a text area with the name "series_id" with the series for
        // weekly earnings, press the submit button, then press the "Retrieve Data"
        // button on the resulting page
        browser.
            fill("series_id", "LES1252881600").
            pressButton(".submit-button", function(err, browser, status) {
                browser.pressButton("Retrieve Data", function(err, browser, status) {
                    // Define the processing function for earnings data 
                    var ths = browser.querySelectorAll("table.regular-data tbody th");
                    for ( var i = 0; i < ths.length; i++) {
                        var earningsEntry = {};

                        var th = ths.item(i);
github OptimalBits / Crawlme / lib / crawlme.js View on Github external
function getHTMLSnapshot(url, noCache, cb) {
    if(!cb){
      cb = noCache;
      noCache = false;
    }

    if(!noCache){
      var cached = cache.get(url);
      if(cached) return cb(null, cached);
    }

    Browser.visit(url, {waitFor: options.waitFor},
      function(err, browser, status) {
        if(err) return cb(err);

        // links
        var links = browser.queryAll('a');
        links.forEach(function(link) {
          var href = link.getAttribute('href');
          if(href !== null) {
            var absoluteUrl = urlParser.resolve(url, href);
            link.setAttribute('href', absoluteUrl);
          }
        });

        var snapshot = stripScripts(browser.html());
        cache.set(url, snapshot);
        cb(null, snapshot);
github trevorquinn / econstats / server.js View on Github external
var retrieveConsumerPriceIndex8284 = function(callback) {
    // Screen scrape BLS web page for latest cpi information
    zombie.visit("http://data.bls.gov/timeseries/CUUR0000SA0", function(err,
            browser, status) {
        var cpiData = [];

        // Grab the cpi table
        var ths = browser.querySelectorAll("table.regular-data tbody th");
        for ( var i = 0; i < ths.length; i++) {
            var cpiEntry = {};

            // Grab each row header and use it to set the year
            var th = ths.item(i);
            var year = th.innerHTML.trim();

            // Grab each cell in the row and use it to set the month and
            // cpi index
            var tds = th.parentNode.getElementsByTagName("td");
            for ( var j = 0; j < tds.length && j < 12; j++) {
github marcuswestin / fun / test / testCases / test-4-compiler.js View on Github external
module.exports['compile\t"'+name+'"'] = function(assert) {
				currentTestCode = code
				if (isFirstTest) { console.log('loading headless browser...'); isFirstTest = false }
				zombie.visit('http://localhost:'+compilerServerPort, function(err, browser, status) {
					if (err) { throw err }
					if (status != 200) { throw new Error("Got bad status from compiler server:", status) }
					var nextAction = function() {
						if (!actions.length) {
							assert.done()
							scheduleCompilerServerShutdown()
							return
						}
						var action = actions.shift()
						try {
							actionHandlers[action.name].apply(this, [assert, browser, nextAction].concat(action.args))
						} catch(e) {
							console.log('compiler threw:', e.stack, '\nThe code that caused the throw:\n', currentTestCode)
						}
					}
					nextAction()
github craigspaeth / backbone-headless-testing / test / integration / todos.js View on Github external
app.listen('5000', function() {
      console.log('Test server listening on 5000');
      Browser.visit('http://localhost:5000', function(err, b) {
        browser = b;
        $ = browser.window.$;
        ajaxSpy = sinon.spy($, 'ajax');
        browser.wait(function(){
          browser.window.$(function(){
            done();
          });
        });
      });
    });
  });
github spmason / expectations / test / zombie.tests.js View on Github external
it('passes all tests', function(done){
        zombie.visit('http://localhost:5000/', function(err, browser, status){
            var lastDuration = 0;

            function checkResults(browser){
                var passes = parseInt(browser.text('#mocha #stats .passes em'), 10),
                    failures = parseInt(browser.text('#mocha #stats .failures em') || '0', 10);
                expect(passes).toBeGreaterThan(-1);
                expect(failures).toEqual(0);

                done();
            }

            function checkTestStatus(){
                browser.wait(function(){
                    var duration = parseFloat(browser.text('#mocha #stats .duration em'), 10);

                    if(duration === lastDuration){
github CodeStory / code-story-devoxx-france / testHomePage.js View on Github external
test("Checking badges", function (done) {
    Browser.visit(home, function (e, browser) {
        expect(browser.query("#badges .badge:nth-child(1) p:contains('Top Committer')")).to.be.ok();
        expect(browser.query("#badges .badge:nth-child(2) p:contains('Fatty Committer')")).to.be.ok();

        expect(browser.query("#badges .badge:nth-child(1) img[src='/badges/topCommiter.png']")).to.be.ok();
        expect(browser.query("#badges .badge:nth-child(2) img[src='/badges/fatty.png']")).to.be.ok();

        done();
    });
});
github blindsey / node-bdd / spec / click_spec.js View on Github external
beforeEach( function() {
      zombie.visit( "http://localhost:1337/", function( error, _browser, status ) {
        if( error ) throw error;
        expect( status ).toBe( 200 );
        browser = _browser;
        asyncSpecDone();
      });
      asyncSpecWait();
    });

zombie

Insanely fast, full-stack, headless browser testing using Node.js

MIT
Latest version published 5 years ago

Package Health Score

56 / 100
Full package analysis