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
2bcc009f
...
2bcc009ff54e0a8a525df98b07873b22d7b8dbd3
authored
2012-12-29 12:27:29 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
migrated xpath tests
1 parent
c61f0f18
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
tests/suites/casper/xpath.js
tests/suites/casper/xpath.js
View file @
2bcc009
...
...
@@ -2,33 +2,33 @@
/*jshint strict:false*/
var
x
=
require
(
'casper'
).
selectXPath
;
casper
.
test
.
comment
(
'XPath'
);
casper
.
start
(
'tests/site/index.html'
,
function
()
{
this
.
test
.
assertExists
({
casper
.
test
.
begin
(
'XPath tests'
,
6
,
function
(
test
)
{
casper
.
start
(
'tests/site/index.html'
,
function
()
{
test
.
assertExists
({
type
:
'xpath'
,
path
:
'/html/body/ul/li[2]'
},
'XPath selector can find an element'
);
this
.
test
.
assertDoesntExist
({
test
.
assertDoesntExist
({
type
:
'xpath'
,
path
:
'/html/body/ol/li[2]'
},
'XPath selector does not retrieve an unexistent element'
);
this
.
test
.
assertExists
(
x
(
'/html/body/ul/li[2]'
),
'selectXPath() shortcut can find an element as well'
);
this
.
test
.
assertEvalEquals
(
function
()
{
test
.
assertExists
(
x
(
'/html/body/ul/li[2]'
),
'selectXPath() shortcut can find an element as well'
);
test
.
assertEvalEquals
(
function
()
{
return
__utils__
.
findAll
({
type
:
'xpath'
,
path
:
'/html/body/ul/li'
}).
length
;
},
3
,
'Correct number of elements are found'
);
});
});
casper
.
thenClick
(
x
(
'/html/body/a[2]'
),
function
()
{
this
.
test
.
assertTitle
(
'CasperJS test form'
,
'Clicking XPath works as expected'
);
casper
.
thenClick
(
x
(
'/html/body/a[2]'
),
function
()
{
test
.
assertTitle
(
'CasperJS test form'
,
'Clicking XPath works as expected'
);
this
.
fill
(
x
(
'/html/body/form'
),
{
email
:
'chuck@norris.com'
});
this
.
test
.
assertEvalEquals
(
function
()
{
test
.
assertEvalEquals
(
function
()
{
return
document
.
querySelector
(
'input[name="email"]'
).
value
;
},
'chuck@norris.com'
,
'Casper.fill() can fill an input[type=text] form field'
);
});
});
casper
.
run
(
function
()
{
this
.
test
.
done
(
6
);
casper
.
run
(
function
()
{
test
.
done
();
});
});
...
...
Please
register
or
sign in
to post a comment