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
02dbc67c
...
02dbc67cd0538e062986225df82fe029d446a16b
authored
2011-11-15 15:42:45 +0100
by
jean-philippe serafin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added Casper.getGlobal()
1 parent
0cddb57a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletions
casper.js
tests/run.js
tests/site/global.html
casper.js
View file @
02dbc67
...
...
@@ -491,7 +491,7 @@
},
/**
* Retrieve current document url.
* Retrieve
s
current document url.
*
* @return String
*/
...
...
@@ -502,6 +502,18 @@
},
/**
* Retrieves global variable.
*
* @param String name The name of the global variable to retrieve
* @return mixed
*/
getGlobal
:
function
(
name
)
{
return
this
.
evaluate
(
function
()
{
return
window
[
window
.
__casper_params__
.
name
];
},
{
'name'
:
name
});
},
/**
* Retrieves current page title, if any.
*
* @return String
...
...
tests/run.js
View file @
02dbc67
...
...
@@ -207,6 +207,12 @@ casper.then(function() {
});
});
// Casper.getGlobal()
casper
.
thenOpen
(
'tests/site/global.html'
,
function
(
self
)
{
self
.
test
.
comment
(
'Casper.getGlobal()'
);
self
.
test
.
assertEquals
(
self
.
getGlobal
(
'myGlobal'
),
'awesome string'
,
'global retrieved'
)
});
// History
casper
.
thenOpen
(
'tests/site/page1.html'
)
...
...
tests/site/global.html
0 → 100644
View file @
02dbc67
<!DOCTYPE html>
<html>
<body>
<script
type=
"text/javascript"
>
var
myGlobal
=
'awesome string'
;
</script>
</body>
</html>
\ No newline at end of file
Please
register
or
sign in
to post a comment