Why the values of parameters of Browser.visit() callback are undefined?

164 views
Skip to first unread message

pinxue

unread,
Feb 2, 2014, 12:46:39 PM2/2/14
to zomb...@googlegroups.com
As API document mentioned, browser.visit() will invoke the callback with (e, browser, status) parameters, but I always get undefined in following code snip. Did I write it wrong?

function test(title)
{
        (function (theTitle){
             var url = "http://myserver/"+theTitle;
             var browser = new Browser();
             browser.visit(url, function (e, b, st) {
                 console.log("e :"+e + ", b :"+b + ", st :" + ", title :"+ theTitle) ; // e, b, st are undefined instead of null, browser ...
                 console.log( browser.html() ); // works
                 console.log( b.html() ); // TypeError: Cannot call method 'html' of undefined, if comment out first log.
    });
       }
       )(title);
}

var titles[] = { ... }
for(var i in titles) test(titles[i]);

PS, 
  "name": "zombie",
  "version": "2.0.0-alpha25"

Assaf Arkin

unread,
Feb 2, 2014, 12:52:46 PM2/2/14
to pinxue, zomb...@googlegroups.com
The docs are for the last stable release 1.4.1.

The 2.0 API is still not finalized, but assume the only callback argument is the error. It works better with test frameworks like Mocha and promises.

You will get a browser as the second argument if you call Browser.visit(), but not if you call visit() on an object you already have access to.


From: pinxue pinxue
Reply: zomb...@googlegroups.com zomb...@googlegroups.com
Date: February 2, 2014 at 9:46:42 AM
To: zomb...@googlegroups.com zomb...@googlegroups.com
Subject:  [zombie-js] Why the values of parameters of Browser.visit() callback are undefined?
--
You received this message because you are subscribed to the Google Groups "zombie.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zombie-js+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

–––––

Subscribe to Weekend Reading, a newsletter about design, code, startup life and the occasional odd

pinxue

unread,
Feb 2, 2014, 1:03:25 PM2/2/14
to zomb...@googlegroups.com, pinxue
It solved my confusion. Thanks for the quick answer! 
Reply all
Reply to author
Forward
0 new messages