Zombie.js Hangs, iFrame doesn't appear to load completely

90 views
Skip to first unread message

Aaron Siladi

unread,
May 26, 2014, 7:45:34 PM5/26/14
to zomb...@googlegroups.com
Hello, I'm new to Zombie.js and trying to use it to QA test some pages in order to verify the script tags they're loading

I'm running into trouble on pages where these script tags are dynamically loaded into an IFRAME

The script hangs without returning the prompt until I press ^-c.  Debug did not give any obvious clues, it appears the event loop is empty, but document ready status is still 'loading'

To give some extra clues: in an earlier version of the code, I did not use browser.wait(), but the script would still intermittently hang.  Sometimes when it hang I'd immediately re-launch it after ^-c and it would complete that time, with no modifications to the code.  However with the function passed to browser.wait() below as in the code below, it hangs every time. 

What am I doing wrong?  How can I troubleshoot this?  Will zombie.js work for what I'm intending?  My code is below.

Thank you!

var Browser = require('zombie');
var _ = require('underscore');
var Q = require('q');
var testURLs = require('./testurls');

module.exports = function(url){
    return processUrl(url);
    function processUrl(url) {   
       
        var d = Q.defer();

        Browser.visit(url, {silent: true, debug:true}, function(err, browser){
            var iFrames = browser.queryAll('iframe');

            function ifrLoaded() {
                console.log('checking iframes...')
                return _(iFrames).every(function(i){
                    return i.contentWindow.document.readyState === 'complete';
                });
            }

            browser.wait(ifrLoaded, function(){
                var allScripts = [];
                _(iFrames).each(function(i){
                    var scripts = i.getElementsByTagName('script');
                    _(scripts).each(function(s){
                        var src = s.getAttribute('src');
                        if (src) allScripts.push(src)
                    });
                });
            });

        });

        return d.promise
    }
}

module.exports(testURLs[2].url).then(function(data){
    console.log(data);
})



Reply all
Reply to author
Forward
0 new messages