zombie icon indicating copy to clipboard operation
zombie copied to clipboard

Javascript-generated content isn't loaded

Open ghost opened this issue 8 years ago • 3 comments
trafficstars

When loading this webpage with zombie.js the full html isn't generated: https://www.acehotel.com/calendar/london/gallery-openhouse

The webpage has some onload functionality that triggers an ajax call to: https://www.acehotel.com/api/calendar/gallery-openhouse/?_=1495320151583 to get and fill in the event details.

However the resulting html doesn't show up when I do this: ` var Browser = require("zombie"); var browser = new Browser();

browser.visit("https://www.acehotel.com/calendar/london/gallery-openhouse", function() { console.log(browser.html()); }); `

Unfortunately my javascript knowledge is limited and I haven't been able to determine what exactly zombie.js is having trouble with. I offer this as a test case because my understanding was that zombie.js is intended to be a lightweight way of getting the html of javascript-generated pages such as this.

Or have I misunderstood what zombie.js is capable of? Are there some kinds of pages for which zombie.js is known to fail to execute the javascript correctly?

ghost avatar May 20 '17 23:05 ghost

I've the same problem

ElishaDev avatar Jul 12 '17 20:07 ElishaDev

Same problem. I doubted it could because look likes it doesn't use phantomjs or chromedriver.

chamnap avatar Sep 06 '17 11:09 chamnap

It's because of timeout error. Zombie is an analog of phantomjs.

var Browser = require("zombie");
var browser = new Browser();
browser.visit("https://stripe.com", 
  function (err) {
    if (err) { console.log('Error:' + err.message); }
    else { console.log('Page loaded successfully'); }
});

Timeout: did not get to load all resources on this page

> browser.visit("https://www.acehotel.com/calendar/london/gallery-openhouse", 
function (err) {
...   if (err) { console.log('Error:' + err.message); }
...   else { console.log('Page loaded successfully'); }
... });

> Error:Timeout: did not get to load all resources on this page

Look here for solution

Add browser.waitDuration = '20s'; before performing .visit.

waitDuration relates to the amount of time Zombie will wait for browsing and resource loading responses. Usually it's not that big of a deal since Zombie is meant to run in testing environments, which are local and fast.

AlexByte avatar Sep 06 '17 13:09 AlexByte