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
acd7739f
...
acd7739f2c7cc1eede6dd6387d8943766ae89b1f
authored
2013-05-06 12:54:49 -0600
by
hexid
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Update docs for getElementsInfo() and getElementsAttribute()
1 parent
fb1a7216
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
10 deletions
docs/modules/casper.rst
docs/modules/casper.rst
View file @
acd7739
...
...
@@ -922,6 +922,25 @@ Retrieves the value of an attribute on the first element matching the provided :
.. index:: DOM
``getElementsAttribute()``
-------------------------------------------------------------------------------
**Signature:** ``getElementsAttribute(String selector, String attribute)``
.. versionadded:: 1.1
Retrieves the values of an attribute on each element matching the provided :doc:`selector
<
../selectors>`::
var casper = require('casper').create();
casper.start('http://www.google.fr/', function() {
require('utils').dump(this.getElementsAttribute('div[title="Google"]', 'title')); // "['Google']"
});
casper.run();
.. index:: DOM
``getElementBounds()``
-------------------------------------------------------------------------------
...
...
@@ -974,31 +993,70 @@ It returns an array of objects with four keys: ``top``, ``left``, ``width`` and
Retrieves information about the first element matching the provided :doc:`selector
<
../selectors>`::
casper.start('http://google.
com
/', function() {
casper.start('http://google.
fr
/', function() {
require('utils').dump(this.getElementInfo('#hplogo'));
});
Gives something like::
{
"nodeName": "div",
"attributes": {
"align": "left",
"dir": "ltr",
"title": "Google",
"id": "hplogo",
"onload": "window.lol
&&
lol()",
"style": "height:110px;width:276px;background:url(/images/srpr/logo1w.png) no-repeat",
"title": "Google"
},
"height": 110,
"html": "
<div
nowrap=
\"nowrap\"
style=
\"color:#777;font-size:16px;font-weight:bold;position:relative;left:214px;top:70px\"
>
France
</div>
",
"nodeName": "div",
"tag": "
<div
dir=
\"ltr\"
title=
\"Google\"
align=
\"left\"
id=
\"hplogo\"
onload=
\"window.lol&&lol()\"
style=
\"height:110px;width:276px;background:url(/images/srpr/logo1w.png)
no-repeat
\"
><div
nowrap=
\"nowrap\"
style=
\"color:#777;font-size:16px;font-weight:bold;position:relative;left:214px;top:70px\"
>
France
</div></div>
",
"text": "France\n",
"visible": true,
"width": 276,
"x": 62,
"y": 76
}
.. index:: DOM
``getElementsInfo()``
-------------------------------------------------------------------------------
**Signature:** ``getElementsInfo(String selector)``
.. versionadded:: 1.1
Retrieves information about all elements matching the provided :doc:`selector
<
../selectors>`::
casper.start('http://google.fr/', function() {
require('utils').dump(this.getElementsInfo('#hplogo'));
});
Gives something like::
[
{
"attributes": {
"align": "left",
"dir": "ltr",
"id": "hplogo",
"onload": "window.lol
&&
lol()",
"style": "background:url(images/srpr/logo3w.png) no-repeat;background-size:275px 95px;height:95px;width:275px"
"style": "height:110px;width:276px;background:url(/images/srpr/logo1w.png) no-repeat",
"title": "Google"
},
"tag": "
<div
dir=
\"ltr\"
title=
\"Google\"
align=
\"left\"
id=
\"hplogo\"
onload=
\"window.lol&&lol()\"
style=
\"background:url(images/srpr/logo3w.png)
no-repeat
;
background-size:275px
95px
;
height:95px
;
width:275px
\"
><div
nowrap=
\"nowrap\"
style=
\"color:#777;font-size:16px;font-weight:bold;position:relative;left:214px;top:70px\"
>
France
</div></div>
"
,
"height": 110
,
"html": "
<div
nowrap=
\"nowrap\"
style=
\"color:#777;font-size:16px;font-weight:bold;position:relative;left:214px;top:70px\"
>
France
</div>
",
"nodeName": "div",
"tag": "
<div
dir=
\"ltr\"
title=
\"Google\"
align=
\"left\"
id=
\"hplogo\"
onload=
\"window.lol&&lol()\"
style=
\"height:110px;width:276px;background:url(/images/srpr/logo1w.png)
no-repeat
\"
><div
nowrap=
\"nowrap\"
style=
\"color:#777;font-size:16px;font-weight:bold;position:relative;left:214px;top:70px\"
>
France
</div></div>
",
"text": "France\n",
"x": 582.5,
"y": 192,
"width": 275,
"height": 95,
"visible": true
"visible": true,
"width": 276,
"x": 62,
"y": 76
}
]
.. index:: Form
...
...
Please
register
or
sign in
to post a comment