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
783e7dfc
...
783e7dfcf57fb2fec77cc6341a0767825b26fb33
authored
2012-12-30 12:36:42 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
updated samples/googletesting.{js|coffee}
1 parent
3da89c4f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
18 deletions
samples/googletesting.coffee
samples/googletesting.js
samples/googletesting.coffee
View file @
783e7df
casper
=
require
(
"casper"
).
create
logLevel
:
"debug"
# Google sample testing.
#
# Usage:
# $ casperjs test googletesting.coffee
casper
.
test
.
begin
'Google search retrieves 10 or more results'
,
5
,
(
test
)
->
casper
.
start
"http://www.google.fr/"
,
->
test
.
assertTitle
"Google"
,
"google homepage title is the one expected"
test
.
assertExists
'form[action="/search"]'
,
"main form is found"
@
fill
'form[action="/search"]'
,
q
:
"foo"
,
true
casper
.
start
"http://www.google.fr/"
,
->
@
test
.
assertTitle
"Google"
,
"google homepage title is the one expected"
@
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"
test
.
assertUrlMatch
/q=foo/
,
"search term has been submitted"
test
.
assertEval
(
->
__utils__
.
findAll
(
"h3.r"
).
length
>=
10
),
"google search for
\"
foo
\"
retrieves 10 or more results"
casper
.
then
->
@
test
.
assertTitle
"foo - Recherche Google"
,
"google title is ok"
@
test
.
assertUrlMatch
/q=foo/
,
"search term has been submitted"
@
test
.
assertEval
(
->
__utils__
.
findAll
(
"h3.r"
).
length
>=
10
),
"google search for
\"
foo
\"
retrieves 10 or more results"
casper
.
run
->
test
.
done
()
casper
.
test
.
begin
"Casperjs.org is first ranked"
,
1
,
(
test
)
->
casper
.
start
"http://www.google.fr/"
,
->
@
fill
"form[action=
\"
/search
\"
]"
,
q
:
"casperjs"
,
true
casper
.
then
->
test
.
assertSelectorContains
".g"
,
"casperjs.org"
,
"casperjs.org is first ranked"
casper
.
run
->
test
.
done
()
casper
.
run
->
@
test
.
renderResults
true
...
...
samples/googletesting.js
View file @
783e7df
...
...
@@ -12,16 +12,32 @@ casper.test.begin('Google search retrieves 10 or more results', 5, function suit
test
.
assertTitle
(
"Google"
,
"google homepage title is the one expected"
);
test
.
assertExists
(
'form[action="/search"]'
,
"main form is found"
);
this
.
fill
(
'form[action="/search"]'
,
{
q
:
"
foo
"
q
:
"
casperjs
"
},
true
);
});
casper
.
then
(
function
()
{
test
.
assertTitle
(
"
!!foo
- Recherche Google"
,
"google title is ok"
);
test
.
assertUrlMatch
(
/q=
foo
/
,
"search term has been submitted"
);
test
.
assertTitle
(
"
casperjs
- Recherche Google"
,
"google title is ok"
);
test
.
assertUrlMatch
(
/q=
casperjs
/
,
"search term has been submitted"
);
test
.
assertEval
(
function
()
{
return
__utils__
.
findAll
(
"h3.r"
).
length
>=
10
;
},
"google search for \"foo\" retrieves 10 or more results"
);
},
"google search for \"casperjs\" retrieves 10 or more results"
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
});
casper
.
test
.
begin
(
'Casperjs.org is first ranked'
,
1
,
function
suite
(
test
)
{
casper
.
start
(
"http://www.google.fr/"
,
function
()
{
this
.
fill
(
'form[action="/search"]'
,
{
q
:
"casperjs"
},
true
);
});
casper
.
then
(
function
()
{
test
.
assertSelectorContains
(
".g"
,
"casperjs.org"
,
"casperjs.org is first ranked"
);
});
casper
.
run
(
function
()
{
...
...
Please
register
or
sign in
to post a comment