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
dfa2c402
...
dfa2c402e643c07f2ef6fe7366fca40b3de34d54
authored
2012-05-09 08:29:10 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixes #110 - google pagination sample doesn't wait for page change
1 parent
c584fb09
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
samples/googlepagination.coffee
samples/googlepagination.coffee
View file @
dfa2c40
...
...
@@ -4,7 +4,7 @@
#
# (all arguments will be used as the query)
casper
=
require
(
'casper'
).
create
()
casper
=
require
(
'casper'
).
create
(
verbose
:
true
,
logLevel
:
"debug"
)
currentPage
=
1
if
casper
.
cli
.
args
.
length
==
0
...
...
@@ -13,7 +13,7 @@ if casper.cli.args.length == 0
processPage
=
->
casper
.
echo
"capturing page
#{
currentPage
}
"
casper
.
capture
"google-results-p
#{
currentPage
}
.png"
casper
.
capture
"google-results-p
#{
currentPage
}
.png"
# don't go too far down the rabbit hole
return
if
currentPage
>=
5
...
...
@@ -21,15 +21,17 @@ processPage = ->
if
casper
.
exists
"#pnnext"
currentPage
++
casper
.
echo
"requesting next page:
#{
currentPage
}
"
casper
.
thenClick
(
"#pnnext"
).
then
(
processPage
)
#casper.thenClick("#pnnext").then(processPage)
url
=
@
getCurrentUrl
()
casper
.
thenClick
(
"#pnnext"
).
then
->
check
=
->
url
!=
@
getCurrentUrl
()
@
waitFor
check
,
processPage
else
casper
.
echo
"that's all, folks."
casper
.
start
'http://google.fr/'
,
->
@
fill
'form[action="/search"]'
,
q
:
casper
.
cli
.
args
.
join
(
' '
),
true
casper
.
then
->
# google's being all ajaxy, wait for results to load...
@
waitForSelector
'table#nav'
,
=>
processPage
(
casper
)
casper
.
then
processPage
casper
.
run
()
...
...
Please
register
or
sign in
to post a comment