refs #917 - fixed selector capture unaware of page zoom factor
Showing
1 changed file
with
21 additions
and
2 deletions
... | @@ -1047,7 +1047,15 @@ Casper.prototype.getElementBounds = function getElementBounds(selector) { | ... | @@ -1047,7 +1047,15 @@ Casper.prototype.getElementBounds = function getElementBounds(selector) { |
1047 | if (!this.exists(selector)) { | 1047 | if (!this.exists(selector)) { |
1048 | throw new CasperError("No element matching selector found: " + selector); | 1048 | throw new CasperError("No element matching selector found: " + selector); |
1049 | } | 1049 | } |
1050 | var zoomFactor = this.page.zoomFactor || 1; | ||
1050 | var clipRect = this.callUtils("getElementBounds", selector); | 1051 | var clipRect = this.callUtils("getElementBounds", selector); |
1052 | if (zoomFactor !== 1) { | ||
1053 | for (var prop in clipRect) { | ||
1054 | if (clipRect.hasOwnProperty(prop)) { | ||
1055 | clipRect[prop] = clipRect[prop] * zoomFactor; | ||
1056 | } | ||
1057 | } | ||
1058 | } | ||
1051 | if (!utils.isClipRect(clipRect)) { | 1059 | if (!utils.isClipRect(clipRect)) { |
1052 | throw new CasperError('Could not fetch boundaries for element matching selector: ' + selector); | 1060 | throw new CasperError('Could not fetch boundaries for element matching selector: ' + selector); |
1053 | } | 1061 | } |
... | @@ -1090,13 +1098,24 @@ Casper.prototype.getElementsInfo = function getElementsInfo(selector) { | ... | @@ -1090,13 +1098,24 @@ Casper.prototype.getElementsInfo = function getElementsInfo(selector) { |
1090 | * @param String selector A DOM CSS3/XPath selector | 1098 | * @param String selector A DOM CSS3/XPath selector |
1091 | * @return Array | 1099 | * @return Array |
1092 | */ | 1100 | */ |
1093 | Casper.prototype.getElementsBounds = function getElementBounds(selector) { | 1101 | Casper.prototype.getElementsBounds = function getElementsBounds(selector) { |
1094 | "use strict"; | 1102 | "use strict"; |
1095 | this.checkStarted(); | 1103 | this.checkStarted(); |
1096 | if (!this.exists(selector)) { | 1104 | if (!this.exists(selector)) { |
1097 | throw new CasperError("No element matching selector found: " + selector); | 1105 | throw new CasperError("No element matching selector found: " + selector); |
1098 | } | 1106 | } |
1099 | return this.callUtils("getElementsBounds", selector); | 1107 | var zoomFactor = this.page.zoomFactor || 1; |
1108 | var clipRects = this.callUtils("getElementsBounds", selector); | ||
1109 | if (zoomFactor !== 1) { | ||
1110 | Array.prototype.forEach.call(clipRects, function(clipRect) { | ||
1111 | for (var prop in clipRect) { | ||
1112 | if (clipRect.hasOwnProperty(prop)) { | ||
1113 | clipRect[prop] = clipRect[prop] * zoomFactor; | ||
1114 | } | ||
1115 | } | ||
1116 | }); | ||
1117 | } | ||
1118 | return clipRects; | ||
1100 | }; | 1119 | }; |
1101 | 1120 | ||
1102 | /** | 1121 | /** | ... | ... |
-
Please register or sign in to post a comment