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
68a80b31
...
68a80b3114e8a199f8fe20d5a3f1283ba8571307
authored
2012-03-13 08:09:59 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed google search form selector in samples
1 parent
09669077
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
9 deletions
samples/googlelinks.coffee
samples/googlelinks.js
samples/googlematch.coffee
samples/googletesting.coffee
samples/googletesting.js
samples/googlelinks.coffee
View file @
68a80b3
...
...
@@ -7,13 +7,13 @@ casper = require('casper').create()
casper
.
start
"http://google.fr/"
,
->
# search for 'casperjs' from google form
@
fill
"form[name=f]"
,
q
:
"casperjs"
,
true
@
fill
'form[action="/search"]'
,
q
:
"casperjs"
,
true
casper
.
then
->
# aggregate results for the 'casperjs' search
links
=
@
evaluate
getLinks
# search for 'phantomjs' from google form
@
fill
"form[name=f]"
,
q
:
"phantomjs"
,
true
@
fill
'form[action="/search"]'
,
q
:
"phantomjs"
,
true
casper
.
then
->
# concat results for the 'phantomjs' search
...
...
samples/googlelinks.js
View file @
68a80b3
...
...
@@ -10,14 +10,14 @@ function getLinks() {
casper
.
start
(
'http://google.fr/'
,
function
(
self
)
{
// search for 'casperjs' from google form
self
.
fill
(
'form[
name=f
]'
,
{
q
:
'casperjs'
},
true
);
self
.
fill
(
'form[
action="/search"
]'
,
{
q
:
'casperjs'
},
true
);
});
casper
.
then
(
function
(
self
)
{
// aggregate results for the 'casperjs' search
links
=
self
.
evaluate
(
getLinks
);
// now search for 'phantomjs' by fillin the form again
self
.
fill
(
'form[
name=f
]'
,
{
q
:
'phantomjs'
},
true
);
self
.
fill
(
'form[
action="/search"
]'
,
{
q
:
'phantomjs'
},
true
);
});
casper
.
then
(
function
(
self
)
{
...
...
samples/googlematch.coffee
View file @
68a80b3
...
...
@@ -30,7 +30,7 @@ casper.echo "Let the match begin between \"#{terms.join '", "'}\"!"
casper
.
start
"http://google.fr/"
casper
.
each
terms
,
(
self
,
term
)
->
@
then
->
@
fill
'form[
name=f
]'
,
{
q
:
term
},
true
@
then
->
@
fill
'form[
action="/search"
]'
,
{
q
:
term
},
true
@
then
->
score
=
@
fetchScore
()
scores
.
push
term
:
term
,
score
:
score
...
...
samples/googletesting.coffee
View file @
68a80b3
...
...
@@ -2,8 +2,8 @@ casper = require('casper').create logLevel: "debug"
casper
.
start
'http://www.google.fr/'
,
->
@
test
.
assertTitle
'Google'
,
'google homepage title is the one expected'
@
test
.
assertExists
'form[
name=f
]'
,
'main form is found'
@
fill
'form[
name=f
]'
,
q
:
'foo'
,
true
@
test
.
assertExists
'form[
action="/search"
]'
,
'main form is found'
@
fill
'form[
action="/search"
]'
,
q
:
'foo'
,
true
casper
.
then
->
@
test
.
assertTitle
'foo - Recherche Google'
,
'google title is ok'
...
...
samples/googletesting.js
View file @
68a80b3
...
...
@@ -4,8 +4,8 @@ var casper = require('casper').create({
casper
.
start
(
'http://www.google.fr/'
,
function
(
self
)
{
self
.
test
.
assertTitle
(
'Google'
,
'google homepage title is the one expected'
);
self
.
test
.
assertExists
(
'form[
name=f
]'
,
'main form is found'
);
self
.
fill
(
'form[
name=f
]'
,
{
self
.
test
.
assertExists
(
'form[
action="/search"
]'
,
'main form is found'
);
self
.
fill
(
'form[
action="/search"
]'
,
{
q
:
'foo'
},
true
);
});
...
...
Please
register
or
sign in
to post a comment