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
11a7feb8
...
11a7feb8b02226bdd965821169e739858b975177
authored
2013-03-04 13:51:20 -0500
by
Chris Bosco
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of github.com:n1k0/casperjs into request-changeurl
2 parents
325d4880
0799a6b7
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
63 additions
and
25 deletions
.jshintconfig
.jshintignore
.travis.yml
bin/bootstrap.js
bin/casperjs
modules/casper.js
modules/cli.js
modules/clientutils.js
modules/colorizer.js
modules/mouse.js
modules/pagestack.js
modules/tester.js
modules/utils.js
modules/xunit.js
tests/site/waitFor.html
tests/suites/casper/wait.js
.jshintconfig
View file @
11a7feb
...
...
@@ -19,7 +19,6 @@
"predef" : [
"exports",
"phantom",
"require",
"window"
]
}
...
...
.jshintignore
View file @
11a7feb
...
...
@@ -2,8 +2,6 @@ docs
modules/vendors
modules/events.js
modules/querystring.js
samples
tests/clitests/tester/
tests/site
tests/testdir
samples/**
tests/**
tmp
...
...
.travis.yml
View file @
11a7feb
...
...
@@ -3,7 +3,7 @@ branches:
-
"
master"
-
"
1.0"
before_script
:
-
"
npm
install
-g
jshint@
0.9.1
"
-
"
npm
install
-g
jshint@
1.0.0
"
-
"
phantomjs
--version"
-
"
export
PHANTOMJS_EXECUTABLE='phantomjs
--local-to-remote-url-access=yes
--ignore-ssl-errors=yes'"
script
:
...
...
bin/bootstrap.js
View file @
11a7feb
...
...
@@ -28,8 +28,8 @@
*
*/
/*global console
phantom requir
e*/
/*jshint maxstatements:30 maxcomplexity:10*/
/*global console
, phantom, require:tru
e*/
/*jshint maxstatements:30
,
maxcomplexity:10*/
// phantom check
if
(
!
phantom
)
{
...
...
bin/casperjs
View file @
11a7feb
...
...
@@ -56,5 +56,5 @@ CASPER_COMMAND.extend(CASPER_ARGS)
try
:
os
.
execvp
(
CASPER_COMMAND
[
0
],
CASPER_COMMAND
)
except
OSError
as
err
:
print
(
(
'Fatal:
%
s; did you install phantomjs?'
%
err
)
)
print
(
'Fatal:
%
s; did you install phantomjs?'
%
err
)
sys
.
exit
(
1
)
...
...
modules/casper.js
View file @
11a7feb
...
...
@@ -28,7 +28,7 @@
*
*/
/*global CasperError
console exports phantom __utils__
patchRequire*/
/*global CasperError
, console, exports, phantom, __utils__,
patchRequire*/
var
require
=
patchRequire
(
require
);
var
colorizer
=
require
(
'colorizer'
);
...
...
@@ -1883,6 +1883,26 @@ Casper.prototype.waitForText = function(pattern, then, onTimeout, timeout) {
};
/**
* Waits until the text on an element matching the provided DOM CSS3/XPath selector
* is changed to a different value.
*
* @param String selector A DOM CSS3/XPath selector
* @param Function then The next step to preform (optional)
* @param Function onTimeout A callback function to call on timeout (optional)
* @param Number timeout The max amount of time to wait, in milliseconds (optional)
* @return Casper
*/
Casper
.
prototype
.
waitForSelectorTextChange
=
function
(
selector
,
then
,
onTimeout
,
timeout
)
{
"use strict"
;
this
.
checkStarted
();
timeout
=
timeout
?
timeout
:
this
.
options
.
waitTimeout
;
var
currentSelectorText
=
this
.
fetchText
(
selector
);
return
this
.
waitFor
(
function
_check
()
{
return
currentSelectorText
!==
this
.
fetchText
(
selector
);
},
then
,
onTimeout
,
timeout
);
};
/**
* Waits until an element matching the provided DOM CSS3/XPath selector does not
* exist in the remote DOM to process a next step.
*
...
...
modules/cli.js
View file @
11a7feb
...
...
@@ -28,7 +28,7 @@
*
*/
/*global CasperError
console exports phantom
patchRequire*/
/*global CasperError
, console, exports, phantom,
patchRequire*/
var
require
=
patchRequire
(
require
);
var
utils
=
require
(
'utils'
);
...
...
modules/clientutils.js
View file @
11a7feb
...
...
@@ -28,7 +28,7 @@
*
*/
/*global console
escape exports NodeList
window*/
/*global console
, escape, exports, NodeList,
window*/
(
function
(
exports
)
{
"use strict"
;
...
...
@@ -76,7 +76,7 @@
* @return string
*/
this
.
decode
=
function
decode
(
str
)
{
/*jshint maxstatements:30 maxcomplexity:30 */
/*jshint maxstatements:30
,
maxcomplexity:30 */
var
c1
,
c2
,
c3
,
c4
,
i
=
0
,
len
=
str
.
length
,
out
=
""
;
while
(
i
<
len
)
{
do
{
...
...
modules/colorizer.js
View file @
11a7feb
...
...
@@ -28,7 +28,7 @@
*
*/
/*global exports
console
patchRequire*/
/*global exports
, console,
patchRequire*/
var
require
=
patchRequire
(
require
);
var
fs
=
require
(
'fs'
);
...
...
modules/mouse.js
View file @
11a7feb
...
...
@@ -28,7 +28,7 @@
*
*/
/*global CasperError
exports
patchRequire*/
/*global CasperError
, exports,
patchRequire*/
var
require
=
patchRequire
(
require
);
var
utils
=
require
(
'utils'
);
...
...
modules/pagestack.js
View file @
11a7feb
...
...
@@ -28,7 +28,7 @@
*
*/
/*global CasperError
console exports phantom
patchRequire*/
/*global CasperError
, console, exports, phantom,
patchRequire*/
var
require
=
patchRequire
(
require
);
var
utils
=
require
(
'utils'
);
...
...
modules/tester.js
View file @
11a7feb
...
...
@@ -28,7 +28,7 @@
*
*/
/*global CasperError
exports phantom __utils__
patchRequire*/
/*global CasperError
, exports, phantom, __utils__,
patchRequire*/
var
require
=
patchRequire
(
require
);
var
fs
=
require
(
'fs'
);
...
...
@@ -666,13 +666,15 @@ Tester.prototype.assertFalsy = function assertFalsy(subject, message) {
Tester
.
prototype
.
assertSelectorHasText
=
Tester
.
prototype
.
assertSelectorContains
=
function
assertSelectorHasText
(
selector
,
text
,
message
)
{
"use strict"
;
var
textFound
=
this
.
casper
.
fetchText
(
selector
).
indexOf
(
text
)
!==
-
1
;
var
got
=
this
.
casper
.
fetchText
(
selector
);
var
textFound
=
got
.
indexOf
(
text
)
!==
-
1
;
return
this
.
assert
(
textFound
,
message
,
{
type
:
"assertSelectorHasText"
,
standard
:
f
(
'Found "%s" within the selector "%s"'
,
text
,
selector
),
values
:
{
selector
:
selector
,
text
:
text
text
:
text
,
actualContent
:
got
}
});
};
...
...
@@ -922,7 +924,7 @@ Tester.prototype.comment = function comment(message) {
*/
Tester
.
prototype
.
done
=
function
done
()
{
"use strict"
;
/*jshint maxstatements:20 maxcomplexity:20*/
/*jshint maxstatements:20
,
maxcomplexity:20*/
var
planned
,
config
=
this
.
currentSuite
.
config
;
if
(
utils
.
isNumber
(
arguments
[
0
]))
{
this
.
casper
.
warn
(
'done() `planned` arg is deprecated as of 1.1'
);
...
...
modules/utils.js
View file @
11a7feb
...
...
@@ -28,7 +28,7 @@
*
*/
/*global CasperError
console exports phantom
patchRequire*/
/*global CasperError
, console, exports, phantom,
patchRequire*/
var
require
=
patchRequire
(
require
);
...
...
modules/xunit.js
View file @
11a7feb
...
...
@@ -28,7 +28,7 @@
*
*/
/*global CasperError
console exports phantom
patchRequire*/
/*global CasperError
, console, exports, phantom,
patchRequire*/
var
require
=
patchRequire
(
require
);
var
utils
=
require
(
'utils'
);
...
...
@@ -166,5 +166,6 @@ XUnitExporter.prototype.setResults = function setResults(results) {
if
(
!
(
results
instanceof
TestSuiteResult
))
{
throw
new
CasperError
(
'Invalid results type.'
);
}
return
this
.
results
=
results
;
this
.
results
=
results
;
return
results
;
};
...
...
tests/site/waitFor.html
View file @
11a7feb
...
...
@@ -11,11 +11,15 @@
<li>
two
</li>
<li>
three
</li>
</ul>
<div
id=
"textChange"
>
Loading...
</div>
<script>
setTimeout
(
function
()
{
var
li
=
document
.
createElement
(
'li'
)
li
.
appendChild
(
document
.
createTextNode
(
'four'
));
document
.
querySelector
(
'ul'
).
appendChild
(
li
);
document
.
getElementById
(
'textChange'
).
innerHTML
=
'Done'
;
},
500
);
</script>
</body>
...
...
tests/suites/casper/wait.js
View file @
11a7feb
...
...
@@ -87,9 +87,23 @@ casper.test.begin('waitForText() tests', 2, function(test) {
});
casper
.
reload
().
waitForText
(
/four/i
,
function
()
{
t
his
.
t
est
.
pass
(
'Casper.waitForText() can wait for regexp'
);
test
.
pass
(
'Casper.waitForText() can wait for regexp'
);
},
function
()
{
this
.
test
.
fail
(
'Casper.waitForText() can wait for regexp'
);
test
.
fail
(
'Casper.waitForText() can wait for regexp'
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
});
casper
.
test
.
begin
(
'waitForSelectorTextChange() tests'
,
1
,
function
(
test
)
{
casper
.
start
(
'tests/site/waitFor.html'
);
casper
.
waitForSelectorTextChange
(
'#textChange'
,
function
()
{
test
.
pass
(
'Casper.waitForSelectorTextChange() can wait for text on a selector to change'
);
},
function
()
{
test
.
fail
(
'Casper.waitForSelectorTextChange() can wait for text on a selector to change'
);
});
casper
.
run
(
function
()
{
...
...
Please
register
or
sign in
to post a comment