lib/checks.js
function waitForString(page, ph, str, callback) {
    var elapsed = 0;
    var currentDom = '';
    var timeout = false;

    async.until(
        function () {
            timeout = elapsed > constants.WAIT_TIMEOUT;
            return currentDom.indexOf(str) > -1 || timeout;
        },

        function (callback) {
            setTimeout(function () {
                getData.takeSnapshot(page, ph, function (error, page, ph, dom) {
                    if (error) {
                        callback(error);
                        return;
                    }
                    currentDom = dom;
                    elapsed += constants.POLL_INTERVAL;
                    callback();
                })
            }, constants.POLL_INTERVAL);
        },

        function (error) {
            if (error) {
                callback(error, page, ph);
                return;
            }
            if (timeout) {
                callback('Timeout while waiting for string', page, ph);
                return;
            }
            callback(null, page, ph);
        }
    );
}
function waitForString(page, ph, str, callback) {
    var elapsed = 0;
    var currentDom = '';
    var timeout = false;

    async.until(
        function () {
            timeout = elapsed > constants.WAIT_TIMEOUT;
            return currentDom.indexOf(str) > -1 || timeout;
        },

        function (callback) {
            setTimeout(function () {
                getData.takeSnapshot(page, ph, function (error, page, ph, dom) {
                    if (error) {
                        callback(error);
                        return;
                    }
                    currentDom = dom;
                    elapsed += constants.POLL_INTERVAL;
                    callback();
                })
            }, constants.POLL_INTERVAL);
        },

        function (error) {
            if (error) {
                callback(error, page, ph);
                return;
            }
            if (timeout) {
                callback('Timeout while waiting for string', page, ph);
                return;
            }
            callback(null, page, ph);
        }
    );
}
function waitForString ( page , ph , str , callback ) { var elapsed = 0 ; var currentDom = '' ; var timeout = false ; async . until ( function ( ) { timeout = elapsed > constants . WAIT_TIMEOUT ; return currentDom . indexOf ( str ) > - 1 || timeout ; } , function ( callback ) { setTimeout ( function ( ) { getData . takeSnapshot ( page , ph , function ( error , page , ph , dom ) { if ( error ) { callback ( error ) ; return ; } currentDom = dom ; elapsed += constants . POLL_INTERVAL ; callback ( ) ; } ) } , constants . POLL_INTERVAL ) ; } , function ( error ) { if ( error ) { callback ( error , page , ph ) ; return ; } if ( timeout ) { callback ( 'Timeout while waiting for string' , page , ph ) ; return ; } callback ( null , page , ph ) ; } ) ; }
Polls the DOM and wait until a certain string is present
@param page
@param ph
@param str
@param {pageCallback} callback
Polls the DOM and wait until a certain string is present