poltergeist 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/capybara/poltergeist/browser.rb +39 -9
- data/lib/capybara/poltergeist/client/agent.coffee +7 -2
- data/lib/capybara/poltergeist/client/browser.coffee +19 -10
- data/lib/capybara/poltergeist/client/compiled/agent.js +4 -2
- data/lib/capybara/poltergeist/client/compiled/browser.js +58 -19
- data/lib/capybara/poltergeist/client/compiled/web_page.js +21 -10
- data/lib/capybara/poltergeist/client/web_page.coffee +19 -6
- data/lib/capybara/poltergeist/driver.rb +4 -4
- data/lib/capybara/poltergeist/node.rb +10 -0
- data/lib/capybara/poltergeist/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eac1d67cd0c1e7872a042e4d0dfa10740b132858
|
4
|
+
data.tar.gz: e52276ce486bb4bda8e17416da7492cdae0af9aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa4a1e4fa49103bb1989d16a46c1135ebffaec9df3fb0a86f1fdf5841389fffd9c6ebaa59ffc8f57abf150a981ce419d38c5c9516d1b0281e73e96f3c78cc517
|
7
|
+
data.tar.gz: a7088f6835bf5ef8eb42e724e99dc3271e37deb56c47cce57d68bdd54493ed0e4ed795717dc10d91a56196c55df59fed3c8bdf2c437c9d387d58cc5e7f0d4cbf
|
@@ -120,12 +120,12 @@ module Capybara::Poltergeist
|
|
120
120
|
command 'click_coordinates', x, y
|
121
121
|
end
|
122
122
|
|
123
|
-
def evaluate(script)
|
124
|
-
command 'evaluate', script
|
123
|
+
def evaluate(script, *args)
|
124
|
+
command 'evaluate', script, *args
|
125
125
|
end
|
126
126
|
|
127
|
-
def execute(script)
|
128
|
-
command 'execute', script
|
127
|
+
def execute(script, *args)
|
128
|
+
command 'execute', script, *args
|
129
129
|
end
|
130
130
|
|
131
131
|
def within_frame(handle, &block)
|
@@ -429,19 +429,49 @@ module Capybara::Poltergeist
|
|
429
429
|
end
|
430
430
|
end
|
431
431
|
|
432
|
+
KEY_ALIASES = {
|
433
|
+
command: :Meta,
|
434
|
+
equals: :Equal,
|
435
|
+
Control: :Ctrl,
|
436
|
+
control: :Ctrl,
|
437
|
+
mulitply: 'numpad*',
|
438
|
+
add: 'numpad+',
|
439
|
+
divide: 'numpad/',
|
440
|
+
subtract: 'numpad-',
|
441
|
+
decimal: 'numpad.'
|
442
|
+
}
|
443
|
+
|
432
444
|
def normalize_keys(keys)
|
433
445
|
keys.map do |key|
|
434
446
|
case key
|
435
447
|
when Array
|
436
448
|
# [:Shift, "s"] => { modifier: "shift", key: "S" }
|
449
|
+
# [:Shift, "string"] => { modifier: "shift", key: "STRING" }
|
437
450
|
# [:Ctrl, :Left] => { modifier: "ctrl", key: :Left }
|
438
451
|
# [:Ctrl, :Shift, :Left] => { modifier: "ctrl,shift", key: :Left }
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
452
|
+
# [:Ctrl, :Left, :Left] => { modifier: "ctrl", key: [:Left, :Left] }
|
453
|
+
_keys = key.chunk {|k| k.is_a?(Symbol) && %w(shift ctrl control alt meta command).include?(k.to_s.downcase) }
|
454
|
+
modifiers = if _keys.peek[0]
|
455
|
+
_keys.next[1].map do |k|
|
456
|
+
k = k.to_s.downcase
|
457
|
+
k = 'ctrl' if k == 'control'
|
458
|
+
k = 'meta' if k == 'command'
|
459
|
+
k
|
460
|
+
end.join(',')
|
461
|
+
else
|
462
|
+
''
|
463
|
+
end
|
464
|
+
letter = normalize_keys(_keys.next[1].map {|k| k.is_a?(String) ? k.upcase : k })
|
465
|
+
{ modifier: modifiers, key: letter }
|
443
466
|
when Symbol
|
444
|
-
|
467
|
+
# Return a known sequence for PhantomJS
|
468
|
+
key = KEY_ALIASES.fetch(key, key)
|
469
|
+
if match = key.to_s.match(/numpad(.)/)
|
470
|
+
res = { key: match[1], modifier: 'keypad' }
|
471
|
+
elsif key !~ /^[A-Z]/
|
472
|
+
key = key.to_s.split('_').map{|e| e.capitalize}.join
|
473
|
+
end
|
474
|
+
res || { key: key }
|
445
475
|
when String
|
446
476
|
key # Plain string, nothing to do
|
447
477
|
end
|
@@ -55,7 +55,7 @@ class PoltergeistAgent
|
|
55
55
|
this.get(id).removeAttribute('_poltergeist_selected')
|
56
56
|
|
57
57
|
clearLocalStorage: ->
|
58
|
-
localStorage
|
58
|
+
localStorage?.clear()
|
59
59
|
|
60
60
|
class PoltergeistAgent.ObsoleteNode
|
61
61
|
toString: -> "PoltergeistAgent.ObsoleteNode"
|
@@ -266,7 +266,12 @@ class PoltergeistAgent.Node
|
|
266
266
|
rect.right <= window.innerWidth
|
267
267
|
|
268
268
|
isDisabled: ->
|
269
|
-
|
269
|
+
xpath = 'parent::optgroup[@disabled] | \
|
270
|
+
ancestor::select[@disabled] | \
|
271
|
+
parent::fieldset[@disabled] | \
|
272
|
+
ancestor::*[not(self::legend) or preceding-sibling::legend][parent::fieldset[@disabled]]'
|
273
|
+
|
274
|
+
@element.disabled || document.evaluate(xpath, @element, null, XPathResult.BOOLEAN_TYPE, null).booleanValue
|
270
275
|
|
271
276
|
path: ->
|
272
277
|
elements = @parentIds().reverse().map((id) => @agent.get(id))
|
@@ -199,11 +199,15 @@ class Poltergeist.Browser
|
|
199
199
|
path: (page_id, id) ->
|
200
200
|
@current_command.sendResponse this.node(page_id, id).path()
|
201
201
|
|
202
|
-
evaluate: (script) ->
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
202
|
+
evaluate: (script, args...) ->
|
203
|
+
for arg in args when @_isElementArgument(arg)
|
204
|
+
throw new Poltergeist.ObsoleteNode if arg["ELEMENT"]["page_id"] != @currentPage.id
|
205
|
+
@current_command.sendResponse @currentPage.evaluate("function() { return #{script} }", args...)
|
206
|
+
|
207
|
+
execute: (script, args...) ->
|
208
|
+
for arg in args when @_isElementArgument(arg)
|
209
|
+
throw new Poltergeist.ObsoleteNode if arg["ELEMENT"]["page_id"] != @currentPage.id
|
210
|
+
@currentPage.execute("function() { #{script} }", args...)
|
207
211
|
@current_command.sendResponse(true)
|
208
212
|
|
209
213
|
frameUrl: (frame_name) ->
|
@@ -345,21 +349,24 @@ class Poltergeist.Browser
|
|
345
349
|
if !target.containsSelection()
|
346
350
|
target.mouseEvent('click')
|
347
351
|
|
352
|
+
@_send_keys_with_modifiers(keys)
|
353
|
+
@current_command.sendResponse(true)
|
354
|
+
|
355
|
+
_send_keys_with_modifiers: (keys, current_modifier_code = 0) ->
|
348
356
|
for sequence in keys
|
349
357
|
key = if sequence.key?
|
350
358
|
@currentPage.keyCode(sequence.key) || sequence.key
|
351
359
|
else
|
352
360
|
sequence
|
361
|
+
|
353
362
|
if sequence.modifier?
|
354
363
|
modifier_keys = @currentPage.keyModifierKeys(sequence.modifier)
|
355
|
-
modifier_code = @currentPage.keyModifierCode(sequence.modifier)
|
364
|
+
modifier_code = @currentPage.keyModifierCode(sequence.modifier) | current_modifier_code
|
356
365
|
@currentPage.sendEvent('keydown', modifier_key) for modifier_key in modifier_keys
|
357
|
-
@
|
366
|
+
@_send_keys_with_modifiers([].concat(key), modifier_code)
|
358
367
|
@currentPage.sendEvent('keyup', modifier_key) for modifier_key in modifier_keys
|
359
368
|
else
|
360
|
-
@currentPage.sendEvent('keypress', key)
|
361
|
-
|
362
|
-
@current_command.sendResponse(true)
|
369
|
+
@currentPage.sendEvent('keypress', key, null, null, current_modifier_code)
|
363
370
|
|
364
371
|
render_base64: (format, { full = false, selector = null } = {})->
|
365
372
|
window_scroll_position = @currentPage.native().evaluate("function(){ return [window.pageXOffset, window.pageYOffset] }")
|
@@ -535,3 +542,5 @@ class Poltergeist.Browser
|
|
535
542
|
wildcard = wildcard.replace(/\?/g, ".")
|
536
543
|
new RegExp(wildcard, "i")
|
537
544
|
|
545
|
+
_isElementArgument: (arg)->
|
546
|
+
typeof(arg) == "object" and typeof(arg['ELEMENT']) == "object"
|
@@ -97,7 +97,7 @@ PoltergeistAgent = (function() {
|
|
97
97
|
};
|
98
98
|
|
99
99
|
PoltergeistAgent.prototype.clearLocalStorage = function() {
|
100
|
-
return localStorage.clear();
|
100
|
+
return typeof localStorage !== "undefined" && localStorage !== null ? localStorage.clear() : void 0;
|
101
101
|
};
|
102
102
|
|
103
103
|
return PoltergeistAgent;
|
@@ -389,7 +389,9 @@ PoltergeistAgent.Node = (function() {
|
|
389
389
|
};
|
390
390
|
|
391
391
|
Node.prototype.isDisabled = function() {
|
392
|
-
|
392
|
+
var xpath;
|
393
|
+
xpath = 'parent::optgroup[@disabled] | ancestor::select[@disabled] | parent::fieldset[@disabled] | ancestor::*[not(self::legend) or preceding-sibling::legend][parent::fieldset[@disabled]]';
|
394
|
+
return this.element.disabled || document.evaluate(xpath, this.element, null, XPathResult.BOOLEAN_TYPE, null).booleanValue;
|
393
395
|
};
|
394
396
|
|
395
397
|
Node.prototype.path = function() {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
var
|
2
|
-
|
1
|
+
var slice = [].slice,
|
2
|
+
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
3
3
|
|
4
4
|
Poltergeist.Browser = (function() {
|
5
5
|
function Browser(width, height) {
|
@@ -249,12 +249,32 @@ Poltergeist.Browser = (function() {
|
|
249
249
|
return this.current_command.sendResponse(this.node(page_id, id).path());
|
250
250
|
};
|
251
251
|
|
252
|
-
Browser.prototype.evaluate = function(
|
253
|
-
|
252
|
+
Browser.prototype.evaluate = function() {
|
253
|
+
var arg, args, i, len, ref, script;
|
254
|
+
script = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
255
|
+
for (i = 0, len = args.length; i < len; i++) {
|
256
|
+
arg = args[i];
|
257
|
+
if (this._isElementArgument(arg)) {
|
258
|
+
if (arg["ELEMENT"]["page_id"] !== this.currentPage.id) {
|
259
|
+
throw new Poltergeist.ObsoleteNode;
|
260
|
+
}
|
261
|
+
}
|
262
|
+
}
|
263
|
+
return this.current_command.sendResponse((ref = this.currentPage).evaluate.apply(ref, ["function() { return " + script + " }"].concat(slice.call(args))));
|
254
264
|
};
|
255
265
|
|
256
|
-
Browser.prototype.execute = function(
|
257
|
-
|
266
|
+
Browser.prototype.execute = function() {
|
267
|
+
var arg, args, i, len, ref, script;
|
268
|
+
script = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
269
|
+
for (i = 0, len = args.length; i < len; i++) {
|
270
|
+
arg = args[i];
|
271
|
+
if (this._isElementArgument(arg)) {
|
272
|
+
if (arg["ELEMENT"]["page_id"] !== this.currentPage.id) {
|
273
|
+
throw new Poltergeist.ObsoleteNode;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
}
|
277
|
+
(ref = this.currentPage).execute.apply(ref, ["function() { " + script + " }"].concat(slice.call(args)));
|
258
278
|
return this.current_command.sendResponse(true);
|
259
279
|
};
|
260
280
|
|
@@ -450,36 +470,51 @@ Poltergeist.Browser = (function() {
|
|
450
470
|
};
|
451
471
|
|
452
472
|
Browser.prototype.send_keys = function(page_id, id, keys) {
|
453
|
-
var
|
473
|
+
var target;
|
454
474
|
target = this.node(page_id, id);
|
455
475
|
if (!target.containsSelection()) {
|
456
476
|
target.mouseEvent('click');
|
457
477
|
}
|
478
|
+
this._send_keys_with_modifiers(keys);
|
479
|
+
return this.current_command.sendResponse(true);
|
480
|
+
};
|
481
|
+
|
482
|
+
Browser.prototype._send_keys_with_modifiers = function(keys, current_modifier_code) {
|
483
|
+
var i, j, key, len, len1, modifier_code, modifier_key, modifier_keys, results, sequence;
|
484
|
+
if (current_modifier_code == null) {
|
485
|
+
current_modifier_code = 0;
|
486
|
+
}
|
487
|
+
results = [];
|
458
488
|
for (i = 0, len = keys.length; i < len; i++) {
|
459
489
|
sequence = keys[i];
|
460
490
|
key = sequence.key != null ? this.currentPage.keyCode(sequence.key) || sequence.key : sequence;
|
461
491
|
if (sequence.modifier != null) {
|
462
492
|
modifier_keys = this.currentPage.keyModifierKeys(sequence.modifier);
|
463
|
-
modifier_code = this.currentPage.keyModifierCode(sequence.modifier);
|
493
|
+
modifier_code = this.currentPage.keyModifierCode(sequence.modifier) | current_modifier_code;
|
464
494
|
for (j = 0, len1 = modifier_keys.length; j < len1; j++) {
|
465
495
|
modifier_key = modifier_keys[j];
|
466
496
|
this.currentPage.sendEvent('keydown', modifier_key);
|
467
497
|
}
|
468
|
-
this.
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
498
|
+
this._send_keys_with_modifiers([].concat(key), modifier_code);
|
499
|
+
results.push((function() {
|
500
|
+
var k, len2, results1;
|
501
|
+
results1 = [];
|
502
|
+
for (k = 0, len2 = modifier_keys.length; k < len2; k++) {
|
503
|
+
modifier_key = modifier_keys[k];
|
504
|
+
results1.push(this.currentPage.sendEvent('keyup', modifier_key));
|
505
|
+
}
|
506
|
+
return results1;
|
507
|
+
}).call(this));
|
473
508
|
} else {
|
474
|
-
this.currentPage.sendEvent('keypress', key);
|
509
|
+
results.push(this.currentPage.sendEvent('keypress', key, null, null, current_modifier_code));
|
475
510
|
}
|
476
511
|
}
|
477
|
-
return
|
512
|
+
return results;
|
478
513
|
};
|
479
514
|
|
480
|
-
Browser.prototype.render_base64 = function(format,
|
515
|
+
Browser.prototype.render_base64 = function(format, arg1) {
|
481
516
|
var dimensions, encoded_image, full, ref, ref1, ref2, ref3, selector, window_scroll_position;
|
482
|
-
ref =
|
517
|
+
ref = arg1 != null ? arg1 : {}, full = (ref1 = ref.full) != null ? ref1 : false, selector = (ref2 = ref.selector) != null ? ref2 : null;
|
483
518
|
window_scroll_position = this.currentPage["native"]().evaluate("function(){ return [window.pageXOffset, window.pageYOffset] }");
|
484
519
|
dimensions = this.set_clip_rect(full, selector);
|
485
520
|
encoded_image = this.currentPage.renderBase64(format);
|
@@ -491,9 +526,9 @@ Poltergeist.Browser = (function() {
|
|
491
526
|
return this.current_command.sendResponse(encoded_image);
|
492
527
|
};
|
493
528
|
|
494
|
-
Browser.prototype.render = function(path,
|
529
|
+
Browser.prototype.render = function(path, arg1) {
|
495
530
|
var dimensions, format, full, options, quality, ref, ref1, ref2, ref3, ref4, ref5, selector, window_scroll_position;
|
496
|
-
ref =
|
531
|
+
ref = arg1 != null ? arg1 : {}, full = (ref1 = ref.full) != null ? ref1 : false, selector = (ref2 = ref.selector) != null ? ref2 : null, format = (ref3 = ref.format) != null ? ref3 : null, quality = (ref4 = ref.quality) != null ? ref4 : null;
|
497
532
|
window_scroll_position = this.currentPage["native"]().evaluate("function(){ return [window.pageXOffset, window.pageYOffset] }");
|
498
533
|
dimensions = this.set_clip_rect(full, selector);
|
499
534
|
options = {};
|
@@ -733,6 +768,10 @@ Poltergeist.Browser = (function() {
|
|
733
768
|
return new RegExp(wildcard, "i");
|
734
769
|
};
|
735
770
|
|
771
|
+
Browser.prototype._isElementArgument = function(arg) {
|
772
|
+
return typeof arg === "object" && typeof arg['ELEMENT'] === "object";
|
773
|
+
};
|
774
|
+
|
736
775
|
return Browser;
|
737
776
|
|
738
777
|
})();
|
@@ -216,24 +216,35 @@ Poltergeist.WebPage = (function() {
|
|
216
216
|
};
|
217
217
|
|
218
218
|
WebPage.prototype.keyCode = function(name) {
|
219
|
+
if (name === "Ctrl") {
|
220
|
+
name = "Control";
|
221
|
+
}
|
219
222
|
return this["native"]().event.key[name];
|
220
223
|
};
|
221
224
|
|
222
225
|
WebPage.prototype.keyModifierCode = function(names) {
|
223
226
|
var modifiers;
|
224
227
|
modifiers = this["native"]().event.modifier;
|
225
|
-
|
228
|
+
return names.split(',').map(function(name) {
|
226
229
|
return modifiers[name];
|
227
|
-
}))
|
228
|
-
|
230
|
+
}).reduce(function(n1, n2) {
|
231
|
+
return n1 | n2;
|
232
|
+
});
|
229
233
|
};
|
230
234
|
|
231
235
|
WebPage.prototype.keyModifierKeys = function(names) {
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
236
|
+
var k, len2, name, ref2, results;
|
237
|
+
ref2 = names.split(',');
|
238
|
+
results = [];
|
239
|
+
for (k = 0, len2 = ref2.length; k < len2; k++) {
|
240
|
+
name = ref2[k];
|
241
|
+
if (!(name !== 'keypad')) {
|
242
|
+
continue;
|
243
|
+
}
|
244
|
+
name = name.charAt(0).toUpperCase() + name.substring(1);
|
245
|
+
results.push(this.keyCode(name));
|
246
|
+
}
|
247
|
+
return results;
|
237
248
|
};
|
238
249
|
|
239
250
|
WebPage.prototype._waitState_until = function(state, callback, timeout, timeout_callback) {
|
@@ -505,13 +516,13 @@ Poltergeist.WebPage = (function() {
|
|
505
516
|
var args, fn, ref2;
|
506
517
|
fn = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
507
518
|
this.injectAgent();
|
508
|
-
return (ref2 = this["native"]()).evaluate.apply(ref2, ["function() { var _result = " + (this.stringifyCall(fn)) + "; return (_result == null) ? undefined : _result; }"].concat(slice.call(args)));
|
519
|
+
return (ref2 = this["native"]()).evaluate.apply(ref2, ["function() { for(var i=0; i < arguments.length; i++){ if ((typeof(arguments[i]) == 'object') && (typeof(arguments[i]['ELEMENT']) == 'object')){ arguments[i] = window.__poltergeist.get(arguments[i]['ELEMENT']['id']).element; } } var _result = " + (this.stringifyCall(fn)) + "; return (_result == null) ? undefined : _result; }"].concat(slice.call(args)));
|
509
520
|
};
|
510
521
|
|
511
522
|
WebPage.prototype.execute = function() {
|
512
523
|
var args, fn, ref2;
|
513
524
|
fn = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
514
|
-
return (ref2 = this["native"]()).evaluate.apply(ref2, ["function() { " + (this.stringifyCall(fn)) + " }"].concat(slice.call(args)));
|
525
|
+
return (ref2 = this["native"]()).evaluate.apply(ref2, ["function() { for(var i=0; i < arguments.length; i++){ if ((typeof(arguments[i]) == 'object') && (typeof(arguments[i]['ELEMENT']) == 'object')){ arguments[i] = window.__poltergeist.get(arguments[i]['ELEMENT']['id']).element; } } " + (this.stringifyCall(fn)) + " }"].concat(slice.call(args)));
|
515
526
|
};
|
516
527
|
|
517
528
|
WebPage.prototype.stringifyCall = function(fn) {
|
@@ -160,16 +160,17 @@ class Poltergeist.WebPage
|
|
160
160
|
this.native().windowName
|
161
161
|
|
162
162
|
keyCode: (name) ->
|
163
|
+
name = "Control" if name == "Ctrl"
|
163
164
|
this.native().event.key[name]
|
164
165
|
|
165
166
|
keyModifierCode: (names) ->
|
166
167
|
modifiers = this.native().event.modifier
|
167
|
-
names
|
168
|
-
names[0] | names[1] # return codes for 1 or 2 modifiers
|
168
|
+
names.split(',').map((name) -> modifiers[name]).reduce((n1,n2) -> n1 | n2)
|
169
169
|
|
170
170
|
keyModifierKeys: (names) ->
|
171
|
-
names.split(',')
|
172
|
-
|
171
|
+
for name in names.split(',') when name isnt 'keypad'
|
172
|
+
name = name.charAt(0).toUpperCase() + name.substring(1)
|
173
|
+
this.keyCode(name)
|
173
174
|
|
174
175
|
_waitState_until: (state, callback, timeout, timeout_callback) ->
|
175
176
|
if (@state == state)
|
@@ -345,11 +346,23 @@ class Poltergeist.WebPage
|
|
345
346
|
|
346
347
|
evaluate: (fn, args...) ->
|
347
348
|
this.injectAgent()
|
348
|
-
this.native().evaluate("function() {
|
349
|
+
this.native().evaluate("function() {
|
350
|
+
for(var i=0; i < arguments.length; i++){
|
351
|
+
if ((typeof(arguments[i]) == 'object') && (typeof(arguments[i]['ELEMENT']) == 'object')){
|
352
|
+
arguments[i] = window.__poltergeist.get(arguments[i]['ELEMENT']['id']).element;
|
353
|
+
}
|
354
|
+
}
|
355
|
+
var _result = #{this.stringifyCall(fn)};
|
349
356
|
return (_result == null) ? undefined : _result; }", args...)
|
350
357
|
|
351
358
|
execute: (fn, args...) ->
|
352
|
-
this.native().evaluate("function() {
|
359
|
+
this.native().evaluate("function() {
|
360
|
+
for(var i=0; i < arguments.length; i++){
|
361
|
+
if ((typeof(arguments[i]) == 'object') && (typeof(arguments[i]['ELEMENT']) == 'object')){
|
362
|
+
arguments[i] = window.__poltergeist.get(arguments[i]['ELEMENT']['id']).element;
|
363
|
+
}
|
364
|
+
}
|
365
|
+
#{this.stringifyCall(fn)} }", args...)
|
353
366
|
|
354
367
|
stringifyCall: (fn) ->
|
355
368
|
"(#{fn.toString()}).apply(this, arguments)"
|
@@ -134,12 +134,12 @@ module Capybara::Poltergeist
|
|
134
134
|
browser.click_coordinates(x, y)
|
135
135
|
end
|
136
136
|
|
137
|
-
def evaluate_script(script)
|
138
|
-
browser.evaluate(script)
|
137
|
+
def evaluate_script(script, *args)
|
138
|
+
browser.evaluate(script, *args.map { |arg| arg.is_a?(Capybara::Poltergeist::Node) ? arg.native : arg})
|
139
139
|
end
|
140
140
|
|
141
|
-
def execute_script(script)
|
142
|
-
browser.execute(script)
|
141
|
+
def execute_script(script, *args)
|
142
|
+
browser.execute(script, *args.map { |arg| arg.is_a?(Capybara::Poltergeist::Node) ? arg.native : arg})
|
143
143
|
nil
|
144
144
|
end
|
145
145
|
|
@@ -168,6 +168,16 @@ module Capybara::Poltergeist
|
|
168
168
|
command :path
|
169
169
|
end
|
170
170
|
|
171
|
+
# @api private
|
172
|
+
def to_json(*)
|
173
|
+
JSON.generate as_json
|
174
|
+
end
|
175
|
+
|
176
|
+
# @api private
|
177
|
+
def as_json(*)
|
178
|
+
{ ELEMENT: {page_id: @page_id, id: @id} }
|
179
|
+
end
|
180
|
+
|
171
181
|
private
|
172
182
|
|
173
183
|
def filter_text(text)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poltergeist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Leighton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -176,14 +176,14 @@ dependencies:
|
|
176
176
|
requirements:
|
177
177
|
- - "~>"
|
178
178
|
- !ruby/object:Gem::Version
|
179
|
-
version: 1.
|
179
|
+
version: 1.12.2
|
180
180
|
type: :development
|
181
181
|
prerelease: false
|
182
182
|
version_requirements: !ruby/object:Gem::Requirement
|
183
183
|
requirements:
|
184
184
|
- - "~>"
|
185
185
|
- !ruby/object:Gem::Version
|
186
|
-
version: 1.
|
186
|
+
version: 1.12.2
|
187
187
|
- !ruby/object:Gem::Dependency
|
188
188
|
name: listen
|
189
189
|
requirement: !ruby/object:Gem::Requirement
|