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
09c19c30
...
09c19c309100f5ea5215dedac5f3c14dfbd85444
authored
2012-07-06 20:24:51 -0700
by
Andrew de Andrade
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Added settings to thenOpen()
1 parent
583868d9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
3 deletions
modules/casper.js
tests/suites/casper/open.js
modules/casper.js
View file @
09c19c3
...
...
@@ -1245,10 +1245,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 @
09c19c3
...
...
@@ -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,6 +91,42 @@ 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
();
...
...
Please
register
or
sign in
to post a comment