Commit a88a5bf2 authored by Sam Saccone's avatar Sam Saccone

tests: Enable dynamic finding of elements

Allowing for multiple lookup selectors.
parent f81ae654
...@@ -103,15 +103,28 @@ module.exports = function Page(browser) { ...@@ -103,15 +103,28 @@ module.exports = function Page(browser) {
return this.tryFindByXpath(xpath); return this.tryFindByXpath(xpath);
}; };
// ----------------- page actions this.findFirstExisting = function () {
this.ensureAppIsVisible = function () { var args = [].slice.call(arguments);
return browser.findElements(webdriver.By.css('#todoapp'))
if (args.length === 0) {
throw new Error('Unable to find any matching elements');
}
return browser.findElements(args.pop())
.then(function (elms) { .then(function (elms) {
if (elms.length > 0) { if (elms.length) {
return true; return elms[0];
} else {
throw new Error('Unable to find application root, did you start your local server?');
} }
return this.findFirstExisting(args);
}.bind(this));
};
// ----------------- page actions
this.ensureAppIsVisible = function () {
return this.findFirstExisting(webdriver.By.css('#todoapp'), webdriver.By.css('.todoapp'))
.thenCatch(function () {
throw new Error('Unable to find application root, did you start your local server?');
}); });
}; };
......
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