Add Node#clickable?

This commit is contained in:
Thomas Walpole 2018-10-18 11:41:54 -07:00
parent f8f872b4c0
commit 5aa5d9675e
6 changed files with 29 additions and 0 deletions

View File

@ -124,6 +124,10 @@ module Capybara::Poltergeist
command 'visible', page_id, id
end
def clickable?(page_id, id)
command 'clickable', page_id, id
end
def disabled?(page_id, id)
command 'disabled', page_id, id
end

View File

@ -210,6 +210,9 @@ class Poltergeist.Browser
visible: (page_id, id) ->
@current_command.sendResponse @node(page_id, id).isVisible()
clickable: (page_id, id) ->
@current_command.sendResponse @node(page_id, id).isClickable()
disabled: (page_id, id) ->
@current_command.sendResponse @node(page_id, id).isDisabled()

View File

@ -260,6 +260,10 @@ Poltergeist.Browser = (function() {
return this.current_command.sendResponse(this.node(page_id, id).isVisible());
};
Browser.prototype.clickable = function(page_id, id) {
return this.current_command.sendResponse(this.node(page_id, id).isClickable());
};
Browser.prototype.disabled = function(page_id, id) {
return this.current_command.sendResponse(this.node(page_id, id).isDisabled());
};

View File

@ -120,6 +120,16 @@ Poltergeist.Node = (function() {
return this.page.mouseEvent('mouseup', final_pos.x, final_pos.y);
};
Node.prototype.isClickable = function(offset) {
var pos, test;
if (offset == null) {
offset = {};
}
pos = this.mouseEventPosition();
test = this.mouseEventTest(pos.x, pos.y);
return test.status === 'success';
};
Node.prototype.isEqual = function(other) {
return this.page === other.page && this.isDOMEqual(other.id);
};

View File

@ -97,6 +97,10 @@ class Poltergeist.Node
@page.mouseEvent('mousedown', position.x, position.y)
@page.mouseEvent('mouseup', final_pos.x, final_pos.y)
isClickable: (offset = {}) ->
pos = @mouseEventPosition()
test = @mouseEventTest(pos.x, pos.y)
test.status == 'success'
isEqual: (other) ->
@page == other.page && @isDOMEqual(other.id)

View File

@ -126,6 +126,10 @@ module Capybara::Poltergeist
command :visible?
end
def clickable?
command :clickable?
end
def checked?
self[:checked]
end