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
a2282c1c
...
a2282c1c2f9f32efce592ee5c3d73c7dfd6caf93
authored
2011-12-08 10:05:02 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed edge case for CasperUtils.visible(), added tests
1 parent
4a42fe7f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
4 deletions
casper.js
tests/run.js
tests/site/visible.html
casper.js
View file @
a2282c1
...
...
@@ -947,7 +947,7 @@
waitWhileSelector
:
function
(
selector
,
then
,
onTimeout
,
timeout
)
{
timeout
=
timeout
?
timeout
:
this
.
defaultWaitTimeout
;
return
this
.
waitFor
(
function
(
self
)
{
return
!
self
.
exists
(
selector
);
return
!
self
.
exists
(
selector
);
},
then
,
onTimeout
,
timeout
);
},
...
...
@@ -981,7 +981,7 @@
waitWhileVisible
:
function
(
selector
,
then
,
onTimeout
,
timeout
)
{
timeout
=
timeout
?
timeout
:
this
.
defaultWaitTimeout
;
return
this
.
waitFor
(
function
(
self
)
{
return
!
self
.
visible
(
selector
);
return
!
self
.
visible
(
selector
);
},
then
,
onTimeout
,
timeout
);
}
};
...
...
@@ -1085,7 +1085,7 @@
this
.
visible
=
function
(
selector
)
{
try
{
var
el
=
document
.
querySelector
(
selector
);
return
el
&&
el
.
offsetHeight
>
0
&&
el
.
offsetWidth
>
0
;
return
el
&&
el
.
style
.
visibility
!==
'hidden'
&&
el
.
offsetHeight
>
0
&&
el
.
offsetWidth
>
0
;
}
catch
(
e
)
{
return
false
;
}
...
...
tests/run.js
View file @
a2282c1
...
...
@@ -247,7 +247,20 @@ casper.then(function(self) {
self
.
thenOpen
(
'tests/site/page1.html'
);
});
// Casper.visible()
casper
.
thenOpen
(
'tests/site/visible.html'
,
function
(
self
)
{
self
.
test
.
comment
(
'Casper.visible()'
);
self
.
test
.
assert
(
self
.
visible
(
'#img1'
),
'Casper.visible() can detect if an element is visible'
);
self
.
test
.
assert
(
!
self
.
visible
(
'#img2'
),
'Casper.visible() can detect if an element is invisible'
);
self
.
test
.
assert
(
!
self
.
visible
(
'#img3'
),
'Casper.visible() can detect if an element is invisible'
);
self
.
waitWhileVisible
(
'#img1'
,
function
(
self
)
{
self
.
test
.
comment
(
'Casper.waitWhileVisible()'
);
self
.
test
.
pass
(
'Casper.waitWhileVisible() can wait while an element is visible'
);
},
function
(
self
)
{
self
.
test
.
comment
(
'Casper.waitWhileVisible()'
);
self
.
test
.
fail
(
'Casper.waitWhileVisible() can wait while an element is visible'
);
},
2000
);
});
// History
casper
...
...
tests/site/visible.html
0 → 100644
View file @
a2282c1
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
<title>
CasperJS test index
</title>
<script>
setTimeout
(
function
()
{
document
.
querySelector
(
'#img1'
).
style
.
display
=
'none'
;
},
1000
);
</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=
"img3"
style=
"visibility:hidden"
>
</body>
</html>
\ No newline at end of file
Please
register
or
sign in
to post a comment