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
cd85a928
...
cd85a92889ea0464c3a1bf2d9440c5b5a329a7b5
authored
2012-07-14 10:49:37 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
closes #173 - Added support for settings to casper.thenOpen
Contributed by @malendrew
2 parents
7bd5c1b5
a3e477cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
4 deletions
modules/casper.js
tests/suites/casper/open.js
modules/casper.js
View file @
cd85a92
...
...
@@ -1269,10 +1269,14 @@ Casper.prototype.thenEvaluate = function thenEvaluate(fn, context) {
* @return Casper
* @see Casper#open
*/
Casper
.
prototype
.
thenOpen
=
function
thenOpen
(
location
,
then
)
{
Casper
.
prototype
.
thenOpen
=
function
thenOpen
(
location
,
settings
,
then
)
{
"use strict"
;
if
(
!
(
settings
&&
!
utils
.
isFunction
(
settings
)))
{
then
=
settings
;
settings
=
null
;
}
this
.
then
(
this
.
createStep
(
function
_step
()
{
this
.
open
(
location
);
this
.
open
(
location
,
settings
);
},
{
skipLog
:
true
}));
...
...
tests/suites/casper/open.js
View file @
cd85a92
...
...
@@ -22,7 +22,31 @@ var t = casper.test, current = 0, tests = [
username
:
'bob'
,
password
:
'sinclar'
},
"Casper.open() used the expected HTTP auth settings"
);
}
},
function
(
settings
)
{
t
.
assertEquals
(
settings
,
{
method
:
"get"
},
"Casper.thenOpen() used the expected GET settings"
);
},
function
(
settings
)
{
t
.
assertEquals
(
settings
,
{
method
:
"post"
,
data
:
"plop=42&chuck=norris"
},
"Casper.thenOpen() used the expected POST settings"
);
},
function
(
settings
)
{
t
.
assertEquals
(
settings
,
{
method
:
"put"
,
data
:
"plop=42&chuck=norris"
},
"Casper.thenOpen() used the expected PUT settings"
);
},
function
(
settings
)
{
t
.
assertEquals
(
settings
,
{
method
:
"get"
,
username
:
'bob'
,
password
:
'sinclar'
},
"Casper.thenOpen() used the expected HTTP auth settings"
);
},
];
casper
.
start
();
...
...
@@ -67,7 +91,43 @@ casper.open('tests/site/index.html', {
t
.
pass
(
"Casper.open() can open and load a location using HTTP auth"
);
});
// GET with thenOpen
casper
.
thenOpen
(
'tests/site/index.html'
).
then
(
function
()
{
t
.
pass
(
"Casper.thenOpen() can open and load a location using GET"
);
});
// POST with thenOpen
casper
.
thenOpen
(
'tests/site/index.html'
,
{
method
:
'post'
,
data
:
{
plop
:
42
,
chuck
:
'norris'
}
},
function
()
{
t
.
pass
(
"Casper.thenOpen() can open and load a location using POST"
);
});
// PUT with thenOpen
casper
.
thenOpen
(
'tests/site/index.html'
,
{
method
:
'put'
,
data
:
{
plop
:
42
,
chuck
:
'norris'
}
},
function
()
{
t
.
pass
(
"Casper.thenOpen() can open and load a location using PUT"
);
});
// HTTP Auth with thenOpen
casper
.
thenOpen
(
'tests/site/index.html'
,
{
method
:
'get'
,
username
:
'bob'
,
password
:
'sinclar'
},
function
()
{
t
.
pass
(
"Casper.thenOpen() can open and load a location using HTTP auth"
);
});
casper
.
run
(
function
()
{
this
.
removeAllListeners
(
'open'
);
t
.
done
();
});
});
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment