Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cherry-pick mouse events at from michiels

  • Loading branch information...
commit 8cf26f3f34bab6c20427d0ca83446aeedece273e 1 parent 24e154a
@exviva authored
View
12 lib/capybara/poltergeist/browser.rb
@@ -145,6 +145,18 @@ def drag(page_id, id, other_id)
command 'drag', page_id, id, other_id
end
+ def mouse_down_at(x, y)
+ command 'mouse_down_at', x, y
+ end
+
+ def mouse_move_at(x, y)
+ command 'mouse_move_at', x, y
+ end
+
+ def mouse_up_at(x, y)
+ command 'mouse_up_at', x, y
+ end
+
def select(page_id, id, value)
command 'select', page_id, id, value
end
View
13 lib/capybara/poltergeist/client/browser.coffee
@@ -69,6 +69,10 @@ class Poltergeist.Browser
else
@owner.sendResponse(response)
+ sendEvent: (eventType, args...) ->
+ @page.sendEvent(eventType, args...)
+ this.sendResponse(true)
+
add_extension: (extension) ->
@page.injectExtension extension
this.sendResponse 'success'
@@ -202,6 +206,15 @@ class Poltergeist.Browser
@page = prev_page if prev_page
this.sendResponse(true)
+ mouse_down_at: (x, y) ->
+ this.sendEvent("mousedown", x, y)
+
+ mouse_move_at: (x, y) ->
+ this.sendEvent("mousemove", x, y)
+
+ mouse_up_at: (x, y) ->
+ this.sendEvent("mouseup", x, y)
+
mouse_event: (page_id, id, name) ->
# Get the node before changing state, in case there is an exception
node = this.node(page_id, id)
View
22 lib/capybara/poltergeist/client/compiled/browser.js
@@ -1,3 +1,5 @@
+var __slice = [].slice;
+
Poltergeist.Browser = (function() {
function Browser(owner, width, height) {
this.owner = owner;
@@ -90,6 +92,14 @@ Poltergeist.Browser = (function() {
}
};
+ Browser.prototype.sendEvent = function() {
+ var args, eventType, _ref;
+
+ eventType = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ (_ref = this.page).sendEvent.apply(_ref, [eventType].concat(__slice.call(args)));
+ return this.sendResponse(true);
+ };
+
Browser.prototype.add_extension = function(extension) {
this.page.injectExtension(extension);
return this.sendResponse('success');
@@ -261,6 +271,18 @@ Poltergeist.Browser = (function() {
return this.sendResponse(true);
};
+ Browser.prototype.mouse_down_at = function(x, y) {
+ return this.sendEvent("mousedown", x, y);
+ };
+
+ Browser.prototype.mouse_move_at = function(x, y) {
+ return this.sendEvent("mousemove", x, y);
+ };
+
+ Browser.prototype.mouse_up_at = function(x, y) {
+ return this.sendEvent("mouseup", x, y);
+ };
+
Browser.prototype.mouse_event = function(page_id, id, name) {
var node,
_this = this;
View
12 lib/capybara/poltergeist/driver.rb
@@ -147,6 +147,18 @@ def window_handles
browser.window_handles
end
+ def mouse_down_at(x, y)
+ browser.mouse_down_at(x, y)
+ end
+
+ def mouse_move_at(x, y)
+ browser.mouse_move_at(x, y)
+ end
+
+ def mouse_up_at(x, y)
+ browser.mouse_up_at(x, y)
+ end
+
def reset!
browser.reset
@started = false
Please sign in to comment.
Something went wrong with that request. Please try again.