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
fe0400c8
...
fe0400c851477def059d26e6b4eb74691dca6aba
authored
2012-05-12 09:40:51 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added xpath basic helpers in clientutils
1 parent
4de595af
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
modules/clientutils.js
modules/clientutils.js
View file @
fe0400c
...
...
@@ -340,6 +340,29 @@
}
};
this
.
getElementByXPath
=
function
getElementByXPath
(
expression
)
{
var
a
=
document
.
evaluate
(
expression
,
document
,
null
,
XPathResult
.
ORDERED_NODE_SNAPSHOT_TYPE
,
null
);
if
(
a
.
snapshotLength
>
0
)
{
return
a
.
snapshotItem
(
0
);
}
};
this
.
getElementsByXPath
=
function
getElementsByXPath
(
expression
)
{
var
nodes
=
[];
var
a
=
document
.
evaluate
(
expression
,
document
,
null
,
XPathResult
.
ORDERED_NODE_SNAPSHOT_TYPE
,
null
);
for
(
var
i
=
0
;
i
<
a
.
snapshotLength
;
i
++
)
{
nodes
.
push
(
a
.
snapshotItem
(
i
));
}
return
nodes
;
};
this
.
removeElementsByXPath
=
function
removeElementsByXPath
(
expression
)
{
var
a
=
document
.
evaluate
(
expression
,
document
,
null
,
XPathResult
.
UNORDERED_NODE_SNAPSHOT_TYPE
,
null
);
for
(
var
i
=
0
;
i
<
a
.
snapshotLength
;
i
++
)
{
a
.
snapshotItem
(
i
).
parentNode
.
removeChild
(
a
.
snapshotItem
(
i
));
}
};
/**
* Logs a message. Will format the message a way CasperJS will be able
* to log phantomjs side.
...
...
Please
register
or
sign in
to post a comment