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
8a3996b6
...
8a3996b6cfc06ff098057afffd94fed17d532ce8
authored
2011-11-10 12:14:42 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added Casper.thenClick() to add a new step for clicking a link (@marchugon)
1 parent
03cd587d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
16 deletions
casper.js
tests/run.js
tests/site/result.html
casper.js
View file @
8a3996b
...
...
@@ -225,21 +225,6 @@
},
/**
* Adds a new navigation step for clicking on a provided link.
*
* @param String selector A DOM CSS3 compatible selector
* @param function then Next step function to execute on page loaded (optional)
* @return Casper
* @see Casper#open
*/
thenClick
:
function
(
selector
,
fallbackToHref
,
then
)
{
this
.
then
(
function
(
self
)
{
self
.
click
(
selector
,
fallbackToHref
);
});
return
typeof
then
===
"function"
?
this
.
then
(
then
)
:
this
;
},
/**
* Logs the HTML code of the current page.
*
* @return Casper
...
...
@@ -649,6 +634,24 @@
},
/**
* Adds a new navigation step for clicking on a provided link selector
* and execute an optional next step.
*
* @param String selector A DOM CSS3 compatible selector
* @param Function then Next step function to execute on page loaded (optional)
* @param Boolean fallbackToHref Whether to try to relocate to the value of any href attribute (default: true)
* @return Casper
* @see Casper#click
* @see Casper#then
*/
thenClick
:
function
(
selector
,
then
,
fallbackToHref
)
{
this
.
then
(
function
(
self
)
{
self
.
click
(
selector
,
fallbackToHref
);
});
return
typeof
then
===
"function"
?
this
.
then
(
then
)
:
this
;
},
/**
* Adds a new navigation step to perform code evaluation within the
* current retrieved page DOM.
*
...
...
tests/run.js
View file @
8a3996b
...
...
@@ -145,6 +145,12 @@ casper.then(function(self) {
self
.
test
.
assertUrlMatch
(
/topic=bar/
,
'fill() select field was submitted'
);
});
// Casper#thenClick()
casper
.
thenClick
(
'body a'
,
function
(
self
)
{
self
.
test
.
comment
(
'Casper.thenClick()'
);
self
.
test
.
assertTitle
(
'CasperJS test index'
,
'thenClick() casper can add a step for clicking a link'
);
});
// Casper#each()
casper
.
test
.
comment
(
'each'
);
casper
.
each
([
1
,
2
,
3
],
function
(
self
,
item
,
i
)
{
...
...
tests/site/result.html
View file @
8a3996b
...
...
@@ -5,6 +5,7 @@
<title>
CasperJS test form result
</title>
</head>
<body>
this is the result page
<p>
this is the result page
</p>
<p><a
href=
"index.html"
>
Return back home
</a></p>
</body>
</html>
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment