Commit acd7739f acd7739f2c7cc1eede6dd6387d8943766ae89b1f by hexid

Update docs for getElementsInfo() and getElementsAttribute()

1 parent fb1a7216
...@@ -922,6 +922,25 @@ Retrieves the value of an attribute on the first element matching the provided : ...@@ -922,6 +922,25 @@ Retrieves the value of an attribute on the first element matching the provided :
922 922
923 .. index:: DOM 923 .. index:: DOM
924 924
925 ``getElementsAttribute()``
926 -------------------------------------------------------------------------------
927
928 **Signature:** ``getElementsAttribute(String selector, String attribute)``
929
930 .. versionadded:: 1.1
931
932 Retrieves the values of an attribute on each element matching the provided :doc:`selector <../selectors>`::
933
934 var casper = require('casper').create();
935
936 casper.start('http://www.google.fr/', function() {
937 require('utils').dump(this.getElementsAttribute('div[title="Google"]', 'title')); // "['Google']"
938 });
939
940 casper.run();
941
942 .. index:: DOM
943
925 ``getElementBounds()`` 944 ``getElementBounds()``
926 ------------------------------------------------------------------------------- 945 -------------------------------------------------------------------------------
927 946
...@@ -974,32 +993,71 @@ It returns an array of objects with four keys: ``top``, ``left``, ``width`` and ...@@ -974,32 +993,71 @@ It returns an array of objects with four keys: ``top``, ``left``, ``width`` and
974 993
975 Retrieves information about the first element matching the provided :doc:`selector <../selectors>`:: 994 Retrieves information about the first element matching the provided :doc:`selector <../selectors>`::
976 995
977 casper.start('http://google.com/', function() { 996 casper.start('http://google.fr/', function() {
978 require('utils').dump(this.getElementInfo('#hplogo')); 997 require('utils').dump(this.getElementInfo('#hplogo'));
979 }); 998 });
980 999
981 Gives something like:: 1000 Gives something like::
982 1001
983 { 1002 {
984 "nodeName": "div",
985 "attributes": { 1003 "attributes": {
986 "dir": "ltr",
987 "title": "Google",
988 "align": "left", 1004 "align": "left",
1005 "dir": "ltr",
989 "id": "hplogo", 1006 "id": "hplogo",
990 "onload": "window.lol&&lol()", 1007 "onload": "window.lol&&lol()",
991 "style": "background:url(images/srpr/logo3w.png) no-repeat;background-size:275px 95px;height:95px;width:275px" 1008 "style": "height:110px;width:276px;background:url(/images/srpr/logo1w.png) no-repeat",
1009 "title": "Google"
992 }, 1010 },
993 "tag": "<div dir=\"ltr\" title=\"Google\" align=\"left\" id=\"hplogo\" onload=\"window.lol&amp;&amp;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>", 1011 "height": 110,
994 "html": "<div nowrap=\"nowrap\" style=\"color:#777;font-size:16px;font-weight:bold;position:relative;left:214px;top:70px\">France</div>", 1012 "html": "<div nowrap=\"nowrap\" style=\"color:#777;font-size:16px;font-weight:bold;position:relative;left:214px;top:70px\">France</div>",
1013 "nodeName": "div",
1014 "tag": "<div dir=\"ltr\" title=\"Google\" align=\"left\" id=\"hplogo\" onload=\"window.lol&amp;&amp;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>",
995 "text": "France\n", 1015 "text": "France\n",
996 "x": 582.5, 1016 "visible": true,
997 "y": 192, 1017 "width": 276,
998 "width": 275, 1018 "x": 62,
999 "height": 95, 1019 "y": 76
1000 "visible": true
1001 } 1020 }
1002 1021
1022 .. index:: DOM
1023
1024 ``getElementsInfo()``
1025 -------------------------------------------------------------------------------
1026
1027 **Signature:** ``getElementsInfo(String selector)``
1028
1029 .. versionadded:: 1.1
1030
1031 Retrieves information about all elements matching the provided :doc:`selector <../selectors>`::
1032
1033 casper.start('http://google.fr/', function() {
1034 require('utils').dump(this.getElementsInfo('#hplogo'));
1035 });
1036
1037 Gives something like::
1038
1039 [
1040 {
1041 "attributes": {
1042 "align": "left",
1043 "dir": "ltr",
1044 "id": "hplogo",
1045 "onload": "window.lol&&lol()",
1046 "style": "height:110px;width:276px;background:url(/images/srpr/logo1w.png) no-repeat",
1047 "title": "Google"
1048 },
1049 "height": 110,
1050 "html": "<div nowrap=\"nowrap\" style=\"color:#777;font-size:16px;font-weight:bold;position:relative;left:214px;top:70px\">France</div>",
1051 "nodeName": "div",
1052 "tag": "<div dir=\"ltr\" title=\"Google\" align=\"left\" id=\"hplogo\" onload=\"window.lol&amp;&amp;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>",
1053 "text": "France\n",
1054 "visible": true,
1055 "width": 276,
1056 "x": 62,
1057 "y": 76
1058 }
1059 ]
1060
1003 .. index:: Form 1061 .. index:: Form
1004 1062
1005 ``getFormValues()`` 1063 ``getFormValues()``
......