Correct use of click() to follow a link?


#1

I’m testing an Ember app and I’ve got a link inside a table.

I can get to the link by the selector:

$('tr:nth-child(1) td:nth-child(3) a')

In my test I have:

click($('tr:nth-child(1) td:nth-child(3) a'));

But after doing console.log(currentURL()); I am not on the link that the above click should have taken me to.

Do I need to be more specific with the link to click? Or am I using click wrong? Or is there a different test helper I should be using?


#2

Click returns a promise.

click($('tr:nth-child(1) td:nth-child(3) a')).then(function () {
   // check currentUrl
});

#3

I’ve tried that. I’ve also tried:

click($('tr:nth-child(1) td:nth-child(3) a'));
andThen(function(){
  console.log(currentURL());

});

And that doesn’t show what should be the correct page.


#4

Can you provide a live jsbin example of this? Using click with andThen, or click(arg).then should both work.

Is there any unusual asynchronous activity that your routes are doing? If so your route transition may still be in progress in the andThen, although now that I say it that seems unlikely.