How would you compare a binding on page 1 to a binding on page 2?

513 views
Skip to first unread message

Roy Collings

unread,
Nov 28, 2012, 11:21:59 AM11/28/12
to ang...@googlegroups.com
... in other words, how can I 'remember' the result of "binding(x)" from page 1 so I can compare it to a "binding(y)" on page 2?

I know it's all asynchronous / uses futures etc..., but I can't find any code that works for this (and it would save me a HUGE amount of time if this check could be automated!). 

Roy Collings

unread,
Nov 28, 2012, 11:24:26 AM11/28/12
to ang...@googlegroups.com
(This is for "e2e" by the way / sorry,forgot to put that in the subject!)

clayton collie

unread,
Nov 28, 2012, 11:25:48 AM11/28/12
to ang...@googlegroups.com
Seems like the work for a service to handle the shared model.

Roy Collings

unread,
Nov 29, 2012, 4:08:01 AM11/29/12
to ang...@googlegroups.com
??

I'm really just looking for the simple code snippet that will either:
  1. wait until binding('x') is fulfilled, then assign the value to a variable and click the link for the next page etc... so I can still compare to value when I'm on other pages. Or 
  2. allow me to recall binding('x') from a previous page somehow.
 binding('x') is fulfilled at some point, because I can do an "expect" against it using a hardcoded string and it works.

Roy Collings

unread,
Nov 30, 2012, 4:04:25 AM11/30/12
to ang...@googlegroups.com
Clayton, can you give a code example that would demonstrate what you mean there?


On Wednesday, November 28, 2012 5:25:48 PM UTC+1, clayton collie wrote:

Roy Collings

unread,
Nov 30, 2012, 10:02:36 AM11/30/12
to ang...@googlegroups.com
Well, during approximately 30-40 hours of researching this seemingly tiny and simple operation in the last 2 weeks, I've been directed to e2e mocks. I've been directed to injection. I've been directed to services ... etc ... all of which have resulted in hours of reading, searching, and trying to learn a sprawling mess of new concepts and so on.

If I can't find a simple piece of actual code that proves this is possible soon, we'll need to ditch Angular E2E altogether for our testing and switch to Selenium. :(

Maybe there's a better way to do it, but if I can get the code to wait until an asynchronous item is 'fulfilled', then assign the value of it to a variable and then proceed with some functionality, then I'm all set. I don't care if it has to wait 1,2,5 or 10 seconds for everything to be fulfilled - the speed of an e2e test is far less important than it's usefulness, so I don't care if it sits doing nothing for 50 seconds to be sure the future has resolved.

I thought this would work (and variations of it) ... but it just never returns anything:

setTimeout(function() {console.log(element('a').text()}, 10000); // or any length of time.

 ... or this, but it just returns 'undefined´, which suggests the callback function is just running immediately:

    console.log(function() {
        return element('li a').text().value;
    }());  // removing the () just dumps a load of code into the console.

Does anyone know how to do this?

... and please don't just send me off to yet another 10 hour adventure. If you have any idea how to code it please share the code!


Roy Collings

unread,
Dec 3, 2012, 8:56:00 AM12/3/12
to ang...@googlegroups.com
"Talk is cheap. Show me the code." -  linus Torvalds.

I solved it.

- Page 1 has a list of employee names. 
- Click one and it takes you to page 2, which is a ´Person detail´page.
- Page1.employee name should equal Page2.person name ...

element('li a').query(function (selectedElements, done) {
  element('li a').click();
  expect(binding('person.name')).toBe(selectedElements.text()); // (".text()" here isn't AngularJS, it's jQuery)
  done();
});

If you have a better way to compare an item on page 1 to an item on page 2, please post it here! :)
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages