Merge pull request #216 from chiefcll/feature-client-scope
Change clientutils to be able to set a global scope
Showing
2 changed files
with
4 additions
and
4 deletions
... | @@ -456,7 +456,7 @@ Casper.prototype.die = function die(message, status) { | ... | @@ -456,7 +456,7 @@ Casper.prototype.die = function die(message, status) { |
456 | */ | 456 | */ |
457 | Casper.prototype.download = function download(url, targetPath, method, data) { | 457 | Casper.prototype.download = function download(url, targetPath, method, data) { |
458 | "use strict"; | 458 | "use strict"; |
459 | var cu = require('clientutils').create(this.options); | 459 | var cu = require('clientutils').create(utils.mergeObjects({}, this.options)); |
460 | try { | 460 | try { |
461 | fs.write(targetPath, cu.decode(this.base64encode(url, method, data)), 'wb'); | 461 | fs.write(targetPath, cu.decode(this.base64encode(url, method, data)), 'wb'); |
462 | this.emit('downloaded.file', targetPath); | 462 | this.emit('downloaded.file', targetPath); | ... | ... |
... | @@ -57,7 +57,7 @@ | ... | @@ -57,7 +57,7 @@ |
57 | 57 | ||
58 | // public members | 58 | // public members |
59 | this.options = options || {}; | 59 | this.options = options || {}; |
60 | 60 | this.options.scope = this.options.scope || document; | |
61 | /** | 61 | /** |
62 | * Clicks on the DOM element behind the provided selector. | 62 | * Clicks on the DOM element behind the provided selector. |
63 | * | 63 | * |
... | @@ -243,7 +243,7 @@ | ... | @@ -243,7 +243,7 @@ |
243 | * @return NodeList|undefined | 243 | * @return NodeList|undefined |
244 | */ | 244 | */ |
245 | this.findAll = function findAll(selector, scope) { | 245 | this.findAll = function findAll(selector, scope) { |
246 | scope = scope || document; | 246 | scope = scope || this.options.scope; |
247 | try { | 247 | try { |
248 | var pSelector = this.processSelector(selector); | 248 | var pSelector = this.processSelector(selector); |
249 | if (pSelector.type === 'xpath') { | 249 | if (pSelector.type === 'xpath') { |
... | @@ -264,7 +264,7 @@ | ... | @@ -264,7 +264,7 @@ |
264 | * @return HTMLElement|undefined | 264 | * @return HTMLElement|undefined |
265 | */ | 265 | */ |
266 | this.findOne = function findOne(selector, scope) { | 266 | this.findOne = function findOne(selector, scope) { |
267 | scope = scope || document; | 267 | scope = scope || this.options.scope; |
268 | try { | 268 | try { |
269 | var pSelector = this.processSelector(selector); | 269 | var pSelector = this.processSelector(selector); |
270 | if (pSelector.type === 'xpath') { | 270 | if (pSelector.type === 'xpath') { | ... | ... |
-
Please register or sign in to post a comment