This should work: browser.wait(element(by.id('some-element')).isPresent);
(source: http://docsplendid.com/archives/209)

Also note, then() returns a PROMISE.  By nature it is asynchronous, so by 
it threads off outside your for loop which doesn't halt and continues until 
completion without finding your element. Needless to say looping 60 times 
is FAR faster than the fraction of a second that takes a promise to 
complete and return.  Besides, browser.refresh() restarts the for loop 
anyway.

Mo

On Monday, May 18, 2015 at 11:32:05 AM UTC-4, Gyanendra Mishra wrote:
>
>  am trying to check element on regular interval and click only if it is 
> present. Some times this element appears in 2-3 minutes. If it is not 
> present, i want to wait for few seconds and then refresh page
>
> Here is what i tried:
>
> for(var i = 1; i < 60; i++){
>     element(that.proposalByOrderPath(num)).isPresent().then(function(result){
>         if(result){
>             console.log(i);
>             return element(that.proposalByOrderPath(num)).click();
>         }
>         else{
>             browser.sleep(15000);
>             browser.refresh();
>        }
>     });
> }
>
> As an output, it prints *60* twice. It clicks on the element once but 
> tries to look again for the element and throws "element not visible" error.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to