0

I'm trying to call a method on an object in window which can have a callback, like this:

it('should be logged in into Facebook', function(done){
  browser.visit('/test').then(function(){
    browser.window.FB.getLoginStatus(function(response) {
      if (response.status === 'connected') done();
    });
  });
});

But the callback is never executed, although I can see the requests in resources. Furthermore, I tried with eval and it does not work either:

it('should be logged in into Facebook', function(done){
  browser.visit('/test').then(function(){
    browser.evaluate( 'FB.getLoginStatus(function(response) { console.log("connected") // does not print; })' );
  });
});

What can be the problem?

Anton
  • 55
  • 1
  • 9
  • So does "browser.visit()" return a promise? – An0nC0d3r Dec 02 '15 at 11:06
  • it does return a promise – Anton Dec 02 '15 at 11:10
  • I'd imagine it is because the promise is never resolved in `.visit()`. This could be because the path you are passing it is unrecognised or unavailable? Try adding a `.catch()` method to see if it is erroring – An0nC0d3r Dec 02 '15 at 11:12
  • it's not that, I can access browser.window and browser.window.FB inside the callback – Anton Dec 02 '15 at 11:13
  • So you do reach the first call back then inside `then()`? You'r on about the second callback? `function(response){}`? – An0nC0d3r Dec 02 '15 at 11:16
  • yeah i'm after the second one, so I'm trying to call a function on an object to test something and then call done if everything is fine but for some reason the callback is not called :( – Anton Dec 02 '15 at 11:23
  • So if you `console.log(response)` directly inside the callback, you don't see anything? – An0nC0d3r Dec 02 '15 at 11:25
  • that's right. if I do browser.evaluate('console.log(123)') then it's fine but not inside the callback... – Anton Dec 02 '15 at 11:34

0 Answers0