Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
977f74e0
...
977f74e006ec78c70d8a137395d3a2bd33b5338d
authored
2013-03-23 09:47:21 -0500
by
Reid Lynch
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix for visible/waitUntilVisible when selector matches multiple elements
1 parent
b87c8630
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
10 deletions
modules/clientutils.js
tests/site/visible.html
tests/site/waitFor.html
tests/suites/casper/visible.js
tests/suites/casper/wait.js
modules/clientutils.js
View file @
977f74e
...
...
@@ -777,12 +777,14 @@
*/
this
.
visible
=
function
visible
(
selector
)
{
try
{
var
comp
,
el
=
this
.
findOne
(
selector
);
var
el
,
comp
,
el
ems
=
this
.
findAll
(
selector
);
if
(
el
)
{
for
(
var
i
=
0
;
i
<
elems
.
length
;
i
++
)
{
el
=
elems
[
i
];
comp
=
window
.
getComputedStyle
(
el
,
null
);
return
comp
.
visibility
!==
'hidden'
&&
comp
.
display
!==
'none'
&&
el
.
offsetHeight
>
0
&&
el
.
offsetWidth
>
0
;
if
(
comp
.
visibility
!==
'hidden'
&&
comp
.
display
!==
'none'
&&
el
.
offsetHeight
>
0
&&
el
.
offsetWidth
>
0
)
return
true
;
}
return
false
;
}
catch
(
e
)
{
...
...
tests/site/visible.html
View file @
977f74e
...
...
@@ -10,8 +10,8 @@
</script>
</head>
<body>
<img
src=
"images/phantom.png"
id=
"img1"
>
<img
src=
"images/phantom.png"
id=
"img2"
style=
"display:none"
>
<img
src=
"images/phantom.png"
id=
"img1"
style=
"display:none"
>
<img
src=
"images/phantom.png"
id=
"img2"
>
<img
src=
"images/phantom.png"
id=
"img3"
style=
"visibility:hidden"
>
</body>
</html>
\ No newline at end of file
...
...
tests/site/waitFor.html
View file @
977f74e
...
...
@@ -15,6 +15,8 @@
Loading...
</div>
<div
id=
"encoded"
>
Voil
à
</div>
<p
style=
"display:none;"
>
I'm hidden.
</p>
<p>
I'm visible.
</p>
<script>
setTimeout
(
function
()
{
var
li
=
document
.
createElement
(
'li'
)
...
...
tests/suites/casper/visible.js
View file @
977f74e
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
begin
(
'visibility tests'
,
4
,
function
(
test
)
{
casper
.
test
.
begin
(
'visibility tests'
,
5
,
function
(
test
)
{
casper
.
start
(
'tests/site/visible.html'
,
function
()
{
test
.
assert
(
this
.
visible
(
'#img1'
),
'Casper.visible() can detect if an element is
visible'
);
test
.
assert
(
!
this
.
visible
(
'#img2'
),
'Casper.visible() can detect if an element is in
visible'
);
test
.
assert
(
!
this
.
visible
(
'#img1'
),
'Casper.visible() can detect if an element is in
visible'
);
test
.
assert
(
this
.
visible
(
'#img2'
),
'Casper.visible() can detect if an element is
visible'
);
test
.
assert
(
!
this
.
visible
(
'#img3'
),
'Casper.visible() can detect if an element is invisible'
);
test
.
assert
(
this
.
visible
(
'img'
),
'Casper.visible() can detect if an element is visible'
);
this
.
waitWhileVisible
(
'#img1'
,
function
()
{
test
.
pass
(
'Casper.waitWhileVisible() can wait while an element is visible'
);
},
function
()
{
...
...
tests/suites/casper/wait.js
View file @
977f74e
...
...
@@ -117,7 +117,7 @@ casper.test.begin('waitForSelectorTextChange() tests', 1, function(test) {
});
});
casper
.
test
.
begin
(
'waitUntilVisible() tests'
,
1
,
function
(
test
)
{
casper
.
test
.
begin
(
'waitUntilVisible() tests'
,
2
,
function
(
test
)
{
casper
.
start
(
'tests/site/waitFor.html'
);
casper
.
waitUntilVisible
(
'li:nth-child(4)'
,
function
()
{
...
...
@@ -126,6 +126,12 @@ casper.test.begin('waitUntilVisible() tests', 1, function(test) {
test
.
fail
(
'Casper.waitUntilVisible() waits for a selector being visible'
);
});
casper
.
waitUntilVisible
(
'p'
,
function
()
{
test
.
pass
(
'Casper.waitUntilVisible() waits for a selector being visible'
);
},
function
()
{
test
.
fail
(
'Casper.waitUntilVisible() waits for a selector being visible'
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
...
...
Please
register
or
sign in
to post a comment