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
3787e0af
...
3787e0afc40993cf0b2360970f4ce61c896063b5
authored
2013-03-29 15:50:52 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixes #438 - getElementAttribute to works with XPath
1 parent
9019a73a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
modules/casper.js
tests/suites/casper/elementattribute.js
modules/casper.js
View file @
3787e0a
...
...
@@ -892,7 +892,7 @@ Casper.prototype.getElementAttr = function getElementAttr(selector, attribute) {
"use strict"
;
this
.
checkStarted
();
return
this
.
evaluate
(
function
_evaluate
(
selector
,
attribute
)
{
return
document
.
querySelector
(
selector
).
getAttribute
(
attribute
);
return
__utils__
.
findOne
(
selector
).
getAttribute
(
attribute
);
},
selector
,
attribute
);
};
...
...
tests/suites/casper/elementattribute.js
View file @
3787e0a
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
begin
(
'getElementAttribute() tests'
,
1
,
function
(
test
)
{
var
x
=
require
(
'casper'
).
selectXPath
;
casper
.
test
.
begin
(
'getElementAttribute() tests'
,
2
,
function
(
test
)
{
casper
.
start
(
'tests/site/elementattribute.html'
,
function
()
{
test
.
assertEquals
(
this
.
getElementAttribute
(
'.testo'
,
'data-stuff'
),
'beautiful string'
,
'Casper.getElementAttribute() works as intended'
);
test
.
assertEquals
(
this
.
getElementAttribute
(
'.testo'
,
'data-stuff'
),
'beautiful string'
,
'Casper.getElementAttribute() works with a CSS selector'
);
test
.
assertEquals
(
this
.
getElementAttribute
(
x
(
'//div[@class]'
),
'data-stuff'
),
'beautiful string'
,
'Casper.getElementAttribute() works with a XPath selector'
);
}).
run
(
function
()
{
test
.
done
();
});
...
...
Please
register
or
sign in
to post a comment