browser.wait

957 views
Skip to first unread message

Rafael Maiolla

unread,
Feb 17, 2014, 7:09:49 PM2/17/14
to zomb...@googlegroups.com
Is this function working?

browser.wait(duration, callback?)
browser.wait(done, callback?)

I tried to use the one that accepts the duration and the other that accepts a done function, but both seems to just call the callback...



Assaf Arkin

unread,
Feb 17, 2014, 7:38:44 PM2/17/14
to zomb...@googlegroups.com
Yes. It will wait until the browser is done processing all events, or duration/function returns true.

--
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.

Rafael Maiolla

unread,
Feb 17, 2014, 7:41:25 PM2/17/14
to zomb...@googlegroups.com
I don't know why, but it is not calling the function in my case. 

And regarding the duration, it is defined as milliseconds?




--
You received this message because you are subscribed to a topic in the Google Groups "zombie.js" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zombie-js/XZaCr2QjE1o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zombie-js+...@googlegroups.com.

Assaf Arkin

unread,
Feb 17, 2014, 7:42:48 PM2/17/14
to zomb...@googlegroups.com, zomb...@googlegroups.com
Yes, duration is in millisecond.

Assaf Arkin

unread,
Feb 17, 2014, 7:56:44 PM2/17/14
to zomb...@googlegroups.com, zomb...@googlegroups.com
If the callback gets called promptly, that's because the browser has nothing more to process. Run with DEBUG true, it will report empty event loop.

Rafael Maiolla

unread,
Feb 17, 2014, 7:57:50 PM2/17/14
to zomb...@googlegroups.com
hmmmm

Yep, that seems to be the case, tks

Prathap Reddy

unread,
Jan 31, 2015, 7:45:43 AM1/31/15
to zomb...@googlegroups.com
@Assaf Below code is not waiting for the process to complete  
 
    var browser = Browser.create();

    //browser.silent = true;
    //browser.debug = false;

    var closeIt = false;

    browser.visit(file, function () {
        browser.wait(function() {
            return (closeIt === true);
        });
    });

    browser.on('console', function (type, data) {
        data = JSON.parse(data);
        closeIt = (parseEvents(data[0], data[1]));
    }); 

    function parseEvents(name, data) {
        return (name === "jasmine.jasmineDone");
    }
Any extra changes required? And thanks for ZombieJS.

Assaf Arkin

unread,
Jan 31, 2015, 2:40:09 PM1/31/15
to zomb...@googlegroups.com, zomb...@googlegroups.com
Check out the source code for how to use the wait function: https://github.com/assaf/zombie/blob/master/src/zombie/browser.coffee#L268




For more options, visit https://groups.google.com/d/optout.

Prathap Reddy

unread,
Jan 31, 2015, 3:11:26 PM1/31/15
to zomb...@googlegroups.com
@Assaf

I have tried below way as per the source  
 
         browser.visit(file, function () {
            browser.wait(function() {
                return (closeIt === true);

            }, function(){} ); 
        }); 
Still not sure why it's not working... I feel that some extra info is needed in Docs on this because most of the apps being tested would be single page apps and where this is a need.

Assaf Arkin

unread,
Jan 31, 2015, 3:22:31 PM1/31/15
to zomb...@googlegroups.com, zomb...@googlegroups.com
Does the callback get called?

Prathap Reddy

unread,
Jan 31, 2015, 3:31:11 PM1/31/15
to zomb...@googlegroups.com
And I tried with below code  

    browser.visit('localhost:8000', function () {
        browser.wait({element : '#_completed'}).then(function() {
            console.log(browser.errors); // Returns []
            console.log(browser.window.querySelector('#_completed_')) // Logs null...
        });
    });

Prathap Reddy

unread,
Jan 31, 2015, 3:32:38 PM1/31/15
to zomb...@googlegroups.com
@Assaf Yes it is called. Please see my last comment. Where in promise resolve I am trying to check if element is available but it returns null. And also checked for errors, but errors also null.

Assaf Arkin

unread,
Jan 31, 2015, 3:38:24 PM1/31/15
to zomb...@googlegroups.com, zomb...@googlegroups.com
You’re checking for errors after a wait, but if there were any errors to report, visit would have reported them. The second wait doesn’t actually do anything.

Prathap Reddy

unread,
Jan 31, 2015, 3:41:46 PM1/31/15
to zomb...@googlegroups.com
I opened the same using Chrome and there are no errors reported. Could you please let me know whether I am using correct syntax.

Assaf Arkin

unread,
Jan 31, 2015, 3:46:34 PM1/31/15
to zomb...@googlegroups.com, zomb...@googlegroups.com
No, you’re not. The second wait is redundant.




On Sat, Jan 31, 2015 at 12:41 PM, Prathap Reddy <svapr...@gmail.com> wrote:

I opened the same using Chrome and there are no errors reported. Could you please let me know whether I am using correct syntax.

--

Prathap Reddy

unread,
Jan 31, 2015, 3:51:16 PM1/31/15
to zomb...@googlegroups.com
Hmm , ok. How can I solve this. I am struck here at this from yesterday :(

Because I am integrating Zombie in my Grunt plugin to run Jasmine specs, but it is closing in the middle...
Reply all
Reply to author
Forward
0 new messages