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) {
// ----------------- DOM element access methods
this.getFocussedElementId = function () {
return browser.switchTo().activeElement().getAttribute('id').then(function (id) {
return id;
});
this.getFocussedElement = function () {
return browser.switchTo().activeElement();
};
this.getEditInputForItemAtIndex = function (index) {
......@@ -71,7 +69,9 @@ module.exports = function Page(browser) {
};
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 () {
......
......@@ -93,7 +93,7 @@ module.exports.todoMVCTest = function (frameworkName, baseUrl, speedMode, laxMod
test.describe('When page is initially opened', function () {
test.it('should focus on the todo input field', function () {
testOps.assertFocussedElementId('new-todo');
testOps.assertEntryIsFocussed();
});
});
......
......@@ -22,9 +22,15 @@ function TestOperations(page) {
});
}
this.assertFocussedElementId = function (expectedId) {
page.getFocussedElementId().then(function (id) {
assert.equal(id, expectedId, 'The focused element did not have the expected id ' + expectedId);
function testElementEquality(elm1, elm2) {
assert.deepEqual(elm1.id_.value_.ELEMENT, elm2.id_.value_.ELEMENT);
}
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