Commit b594e306 authored by Sam Saccone's avatar Sam Saccone

Fix stale element error

By converting the find and click to a 1 op this avoides the issue of a
stale element.
parent b5cde6ca
......@@ -43,8 +43,20 @@ module.exports = function Page(browser) {
return !idSelectors ? '//span[@id="todo-count"]' : '//span[contains(@class, "todo-count")]';
};
this.getFilterElementsXpath = function () {
return !idSelectors ? '//ul[@id="filters"]//a' : '//ul[contains(@class, "filters")]//a';
this.getFiltersElementXpath = function () {
return !idSelectors ? '//ul[@id="filters"]' : '//ul[contains(@class, "filters")]';
};
this.getFilterAllXpath = function () {
return this.getFiltersElementXpath() + '/li[1]/a';
};
this.getFilterActiveXpath = function () {
return this.getFiltersElementXpath() + '/li[2]/a';
};
this.getFilterCompletedXpath = function () {
return this.getFiltersElementXpath() + '/li[3]/a';
};
this.xPathForItemAtIndex = function (index) {
......@@ -211,20 +223,14 @@ module.exports = function Page(browser) {
};
this.filterByActiveItems = function () {
return this.getFilterElements().then(function (filters) {
filters[1].click();
});
return this.findByXpath(this.getFilterActiveXpath()).click();
};
this.filterByCompletedItems = function () {
return this.getFilterElements().then(function (filters) {
filters[2].click();
});
return this.findByXpath(this.getFilterCompletedXpath()).click();
};
this.filterByAllItems = function () {
return this.getFilterElements().then(function (filters) {
filters[0].click();
});
return this.findByXpath(this.getFilterAllXpath()).click();
};
};
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