Commit f01ca24f authored by Sam Saccone's avatar Sam Saccone

tests: Add dynamic input focus test

parent 47f618e6
...@@ -59,10 +59,8 @@ module.exports = function Page(browser) { ...@@ -59,10 +59,8 @@ module.exports = function Page(browser) {
// ----------------- DOM element access methods // ----------------- DOM element access methods
this.getFocussedElementId = function () { this.getFocussedElement = function () {
return browser.switchTo().activeElement().getAttribute('id').then(function (id) { return browser.switchTo().activeElement();
return id;
});
}; };
this.getEditInputForItemAtIndex = function (index) { this.getEditInputForItemAtIndex = function (index) {
...@@ -71,7 +69,9 @@ module.exports = function Page(browser) { ...@@ -71,7 +69,9 @@ module.exports = function Page(browser) {
}; };
this.getItemInputField = function () { this.getItemInputField = function () {
return this.findByXpath('//input[@id="new-todo"]'); return this.findFirstExisting(
webdriver.By.xpath('//input[@id="new-todo"]'),
webdriver.By.css('input.new-todo'));
}; };
this.getMarkAllCompletedCheckBox = function () { this.getMarkAllCompletedCheckBox = function () {
......
...@@ -93,7 +93,7 @@ module.exports.todoMVCTest = function (frameworkName, baseUrl, speedMode, laxMod ...@@ -93,7 +93,7 @@ module.exports.todoMVCTest = function (frameworkName, baseUrl, speedMode, laxMod
test.describe('When page is initially opened', function () { test.describe('When page is initially opened', function () {
test.it('should focus on the todo input field', function () { test.it('should focus on the todo input field', function () {
testOps.assertFocussedElementId('new-todo'); testOps.assertEntryIsFocussed();
}); });
}); });
......
...@@ -22,9 +22,15 @@ function TestOperations(page) { ...@@ -22,9 +22,15 @@ function TestOperations(page) {
}); });
} }
this.assertFocussedElementId = function (expectedId) { function testElementEquality(elm1, elm2) {
page.getFocussedElementId().then(function (id) { assert.deepEqual(elm1.id_.value_.ELEMENT, elm2.id_.value_.ELEMENT);
assert.equal(id, expectedId, 'The focused element did not have the expected id ' + expectedId); }
this.assertEntryIsFocussed = function () {
return page.getItemInputField().then(function (elm) {
return page.getFocussedElement().then(function (activeElm) {
testElementEquality(elm, activeElm);
});
}); });
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment