Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
todomvc
Commits
8ccca748
Commit
8ccca748
authored
9 years ago
by
Sam Saccone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stale element fix for selected filter.
parent
b594e306
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
30 deletions
+14
-30
tests/page.js
tests/page.js
+11
-7
tests/testOperations.js
tests/testOperations.js
+3
-23
No files found.
tests/page.js
View file @
8ccca748
...
...
@@ -47,16 +47,24 @@ module.exports = function Page(browser) {
return
!
idSelectors
?
'
//ul[@id="filters"]
'
:
'
//ul[contains(@class, "filters")]
'
;
};
this
.
getFilterXpathByIndex
=
function
(
index
)
{
return
this
.
getFiltersElementXpath
()
+
'
/li[
'
+
index
+
'
]/a
'
;
};
this
.
getSelectedFilterXPathByIndex
=
function
(
index
)
{
return
this
.
getFilterXpathByIndex
(
index
)
+
'
[contains(@class, "selected")]
'
;
};
this
.
getFilterAllXpath
=
function
()
{
return
this
.
getFilter
sElementXpath
()
+
'
/li[1]/a
'
;
return
this
.
getFilter
XpathByIndex
(
1
)
;
};
this
.
getFilterActiveXpath
=
function
()
{
return
this
.
getFilter
sElementXpath
()
+
'
/li[2]/a
'
;
return
this
.
getFilter
XpathByIndex
(
2
)
;
};
this
.
getFilterCompletedXpath
=
function
()
{
return
this
.
getFilter
sElementXpath
()
+
'
/li[3]/a
'
;
return
this
.
getFilter
XpathByIndex
(
3
)
;
};
this
.
xPathForItemAtIndex
=
function
(
index
)
{
...
...
@@ -133,10 +141,6 @@ module.exports = function Page(browser) {
return
this
.
findByXpath
(
this
.
xPathForItemAtIndex
(
index
)
+
'
//label
'
);
};
this
.
getFilterElements
=
function
()
{
return
this
.
tryFindByXpath
(
this
.
getFilterElementsXpath
());
};
this
.
getItemLabels
=
function
()
{
var
xpath
=
this
.
getTodoListXpath
()
+
'
/li//label
'
;
return
this
.
tryFindByXpath
(
xpath
);
...
...
This diff is collapsed.
Click to expand it.
tests/testOperations.js
View file @
8ccca748
...
...
@@ -173,30 +173,10 @@ function TestOperations(page) {
});
};
function
isSelected
(
cssClass
)
{
return
cssClass
.
indexOf
(
'
selected
'
)
!==
-
1
;
}
this
.
assertFilterAtIndexIsSelected
=
function
(
selectedIndex
)
{
page
.
getFilterElements
().
then
(
function
(
filterElements
)
{
// create an array of promises, each one holding a test
var
tests
=
[];
// push a test into the array, avoiding the classic JS for loops + closures issue!
function
pushTest
(
itemIndex
)
{
tests
.
push
(
filterElements
[
itemIndex
].
getAttribute
(
'
class
'
).
then
(
function
(
cssClass
)
{
assert
(
selectedIndex
===
itemIndex
?
isSelected
(
cssClass
)
:
!
isSelected
(
cssClass
),
'
the filter / route at index
'
+
selectedIndex
+
'
should have been selected
'
);
}));
}
for
(
var
i
=
0
;
i
<
3
;
i
++
)
{
pushTest
(
i
);
}
// execute all the tests
return
Q
.
all
(
tests
);
page
.
findByXpath
(
page
.
getSelectedFilterXPathByIndex
(
selectedIndex
+
1
))
.
then
(
function
(
elm
)
{
assert
.
notEqual
(
undefined
,
elm
,
'
the filter / route at index
'
+
selectedIndex
+
'
should have been selected
'
);
});
};
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment