Created
December 3, 2012 17:11
-
-
Save roycollings/4196422 to your computer and use it in GitHub Desktop.
AngularJS E2E: (futures) compare a value on page A with a value on page B.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 2 pages: | |
// A: "Employee" page containing a link to an employee. | |
// B: "Person" page - click employee and it brings you here. | |
// There is an AngularJS binding called "person.name" which | |
// should match the Employee's name you clicked on. | |
// | |
describe('The link in the Employee screen', function() { | |
it('takes you to the correct "Person" page', function() { | |
element('a').query(function (selectedElements, done) { | |
element('a').click(); // Click this list item. | |
// The "selectedElements.text()" is getting this string "<a ..> HERE </a>" | |
// from the link. | |
// | |
// (NOTE: This is a JQuery ".text()", NOT an Angular one!) | |
expect(binding('person.name')).toBe(selectedElements.text()); | |
done(); | |
}); | |
}); | |
}); | |
// | |
// If it's a list of links, then use $(this).text() ... or any jQuery method that works: | |
// | |
var elementSel = 'li a:eq(0)'; | |
element(elementSel).query(function (selectedElements, done) { | |
selectedElements.each(function(idx,elm) { | |
var clickedHref = $(this).attr("href").replace(/./,'/'); // JQuery methods, NOT AngularJS. | |
element('li a:eq(' + idx + ')').click(); | |
expect(browser().location().url()).toBe(clickedHref); | |
browser().navigateTo("/app/index.html"); // Prepare to test the next link in the loop. | |
}); | |
done(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A possible alternative (but I can't get e2e components to work in the final setInterval function!):