2016-03-07 19:52:19 -05:00
|
|
|
# frozen_string_literal: true
|
2018-01-08 15:23:54 -05:00
|
|
|
|
2018-08-17 16:57:12 -04:00
|
|
|
# Selenium specific implementation of the Capybara::Driver::Node API
|
2011-04-11 01:24:00 -04:00
|
|
|
class Capybara::Selenium::Node < Capybara::Driver::Node
|
2013-02-17 08:58:41 -05:00
|
|
|
def visible_text
|
2018-03-05 17:57:33 -05:00
|
|
|
native.text
|
2011-04-11 01:24:00 -04:00
|
|
|
end
|
|
|
|
|
2013-02-17 08:58:41 -05:00
|
|
|
def all_text
|
2018-07-10 17:18:39 -04:00
|
|
|
text = driver.execute_script('return arguments[0].textContent', self)
|
2018-03-05 17:57:33 -05:00
|
|
|
text.gsub(/[\u200b\u200e\u200f]/, '')
|
|
|
|
.gsub(/[\ \n\f\t\v\u2028\u2029]+/, ' ')
|
2018-07-10 17:18:39 -04:00
|
|
|
.gsub(/\A[[:space:]&&[^\u00a0]]+/, '')
|
|
|
|
.gsub(/[[:space:]&&[^\u00a0]]+\z/, '')
|
2018-03-05 17:57:33 -05:00
|
|
|
.tr("\u00a0", ' ')
|
2013-02-17 08:58:41 -05:00
|
|
|
end
|
|
|
|
|
2011-04-11 01:24:00 -04:00
|
|
|
def [](name)
|
2012-10-26 09:14:56 -04:00
|
|
|
native.attribute(name.to_s)
|
2011-04-11 01:24:00 -04:00
|
|
|
rescue Selenium::WebDriver::Error::WebDriverError
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def value
|
2018-07-10 17:18:39 -04:00
|
|
|
if tag_name == 'select' && multiple?
|
2018-08-20 19:46:31 -04:00
|
|
|
native.find_elements(:css, 'option:checked').map { |el| el[:value] || el.text }
|
2011-04-11 01:24:00 -04:00
|
|
|
else
|
2011-04-28 15:30:01 -04:00
|
|
|
native[:value]
|
2011-04-11 01:24:00 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-06-19 16:34:54 -04:00
|
|
|
def style(styles)
|
2018-06-20 14:43:21 -04:00
|
|
|
styles.each_with_object({}) do |style, result|
|
|
|
|
result[style] = native.css_value(style)
|
2018-06-19 16:34:54 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-13 00:25:13 -04:00
|
|
|
##
|
|
|
|
#
|
|
|
|
# Set the value of the form element to the given value.
|
|
|
|
#
|
|
|
|
# @param [String] value The new value
|
|
|
|
# @param [Hash{}] options Driver specific options for how to set the value
|
|
|
|
# @option options [Symbol,Array] :clear (nil) The method used to clear the previous value <br/>
|
|
|
|
# nil => clear via javascript <br/>
|
|
|
|
# :none => append the new value to the existing value <br/>
|
|
|
|
# :backspace => send backspace keystrokes to clear the field <br/>
|
|
|
|
# Array => an array of keys to send before the value being set, e.g. [[:command, 'a'], :backspace]
|
2016-08-17 19:14:39 -04:00
|
|
|
def set(value, **options)
|
2018-01-11 19:45:50 -05:00
|
|
|
raise ArgumentError, "Value cannot be an Array when 'multiple' attribute is not present. Not a #{value.class}" if value.is_a?(Array) && !multiple?
|
2017-08-01 16:59:17 -04:00
|
|
|
case tag_name
|
|
|
|
when 'input'
|
2018-01-13 16:06:03 -05:00
|
|
|
case self[:type]
|
2017-08-01 16:59:17 -04:00
|
|
|
when 'radio'
|
|
|
|
click
|
|
|
|
when 'checkbox'
|
2018-01-11 19:45:50 -05:00
|
|
|
click if value ^ checked?
|
2017-08-01 16:59:17 -04:00
|
|
|
when 'file'
|
2017-11-13 16:04:47 -05:00
|
|
|
set_file(value)
|
2018-03-09 17:23:52 -05:00
|
|
|
when 'date'
|
|
|
|
set_date(value)
|
|
|
|
when 'time'
|
|
|
|
set_time(value)
|
|
|
|
when 'datetime-local'
|
|
|
|
set_datetime_local(value)
|
2016-10-18 14:09:26 -04:00
|
|
|
else
|
2017-08-01 16:59:17 -04:00
|
|
|
set_text(value, options)
|
2016-10-18 14:09:26 -04:00
|
|
|
end
|
2017-08-01 16:59:17 -04:00
|
|
|
when 'textarea'
|
|
|
|
set_text(value, options)
|
|
|
|
else
|
2018-01-09 17:05:50 -05:00
|
|
|
set_content_editable(value) if content_editable?
|
2011-04-11 01:24:00 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def select_option
|
2018-08-24 07:45:19 -04:00
|
|
|
click unless selected? || disabled?
|
2011-04-11 01:24:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def unselect_option
|
2018-07-10 17:18:39 -04:00
|
|
|
raise Capybara::UnselectNotAllowed, 'Cannot unselect option from single select box.' unless select_node.multiple?
|
2018-08-24 07:45:19 -04:00
|
|
|
click if selected?
|
2011-04-11 01:24:00 -04:00
|
|
|
end
|
|
|
|
|
2018-05-17 17:45:53 -04:00
|
|
|
def click(keys = [], **options)
|
2018-08-17 16:57:12 -04:00
|
|
|
click_options = ClickOptions.new(keys, options)
|
|
|
|
return native.click if click_options.empty?
|
2018-09-01 14:20:11 -04:00
|
|
|
click_with_options(click_options)
|
2018-08-20 19:46:31 -04:00
|
|
|
rescue StandardError => err
|
|
|
|
if err.is_a?(::Selenium::WebDriver::Error::ElementClickInterceptedError) ||
|
|
|
|
err.message =~ /Other element would receive the click/
|
2018-05-15 12:17:09 -04:00
|
|
|
scroll_to_center
|
2017-10-02 14:55:13 -04:00
|
|
|
end
|
2018-06-06 16:21:33 -04:00
|
|
|
|
2018-08-20 19:46:31 -04:00
|
|
|
raise err
|
2011-04-11 01:24:00 -04:00
|
|
|
end
|
2015-04-13 12:24:13 -04:00
|
|
|
|
2018-05-17 17:45:53 -04:00
|
|
|
def right_click(keys = [], **options)
|
2018-08-17 16:57:12 -04:00
|
|
|
click_options = ClickOptions.new(keys, options)
|
2018-09-01 14:20:11 -04:00
|
|
|
click_with_options(click_options) do |action|
|
|
|
|
click_options.coords? ? action.context_click : action.context_click(native)
|
2017-11-16 21:32:26 -05:00
|
|
|
end
|
2013-05-10 12:55:17 -04:00
|
|
|
end
|
2015-04-13 12:24:13 -04:00
|
|
|
|
2018-05-17 17:45:53 -04:00
|
|
|
def double_click(keys = [], **options)
|
2018-08-17 16:57:12 -04:00
|
|
|
click_options = ClickOptions.new(keys, options)
|
2018-09-01 14:20:11 -04:00
|
|
|
click_with_options(click_options) do |action|
|
|
|
|
click_options.coords? ? action.double_click : action.double_click(native)
|
2017-11-16 21:32:26 -05:00
|
|
|
end
|
2013-05-10 12:55:17 -04:00
|
|
|
end
|
2015-04-13 12:24:13 -04:00
|
|
|
|
2015-01-23 15:23:57 -05:00
|
|
|
def send_keys(*args)
|
|
|
|
native.send_keys(*args)
|
|
|
|
end
|
2011-04-11 01:24:00 -04:00
|
|
|
|
2013-02-25 13:37:25 -05:00
|
|
|
def hover
|
2018-08-17 16:57:12 -04:00
|
|
|
scroll_if_needed { browser_action.move_to(native).perform }
|
2013-02-25 13:37:25 -05:00
|
|
|
end
|
2012-12-14 19:06:50 -05:00
|
|
|
|
2011-04-11 01:24:00 -04:00
|
|
|
def drag_to(element)
|
2018-08-31 17:24:30 -04:00
|
|
|
# Due to W3C spec compliance - The Actions API no longer scrolls to elements when necessary
|
|
|
|
# which means Seleniums `drag_and_drop` is now broken - do it manually
|
|
|
|
scroll_if_needed { browser_action.click_and_hold(native).perform }
|
|
|
|
element.scroll_if_needed { browser_action.move_to(element.native).release.perform }
|
2011-04-11 01:24:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def tag_name
|
2012-10-26 09:14:56 -04:00
|
|
|
native.tag_name.downcase
|
2011-04-11 01:24:00 -04:00
|
|
|
end
|
|
|
|
|
2018-01-13 16:06:03 -05:00
|
|
|
def visible?; boolean_attr(native.displayed?); end
|
|
|
|
def readonly?; boolean_attr(self[:readonly]); end
|
|
|
|
def multiple?; boolean_attr(self[:multiple]); end
|
|
|
|
def selected?; boolean_attr(native.selected?); end
|
2016-06-11 15:09:23 -04:00
|
|
|
alias :checked? :selected?
|
2011-04-11 01:24:00 -04:00
|
|
|
|
2013-01-29 05:45:24 -05:00
|
|
|
def disabled?
|
2018-06-27 13:19:47 -04:00
|
|
|
return true unless native.enabled?
|
|
|
|
# WebDriver only defines `disabled?` for form controls but fieldset makes sense too
|
2018-07-10 17:18:39 -04:00
|
|
|
tag_name == 'fieldset' && find_xpath('ancestor-or-self::fieldset[@disabled]').any?
|
2013-01-29 05:45:24 -05:00
|
|
|
end
|
|
|
|
|
2017-08-01 16:59:17 -04:00
|
|
|
def content_editable?
|
|
|
|
native.attribute('isContentEditable')
|
|
|
|
end
|
|
|
|
|
2013-02-19 12:03:26 -05:00
|
|
|
def find_xpath(locator)
|
2018-08-20 19:46:31 -04:00
|
|
|
native.find_elements(:xpath, locator).map { |el| self.class.new(driver, el) }
|
2011-04-11 01:24:00 -04:00
|
|
|
end
|
2012-12-14 19:06:50 -05:00
|
|
|
|
2013-02-19 12:03:26 -05:00
|
|
|
def find_css(locator)
|
2018-08-20 19:46:31 -04:00
|
|
|
native.find_elements(:css, locator).map { |el| self.class.new(driver, el) }
|
2013-02-19 12:03:26 -05:00
|
|
|
end
|
2012-12-14 19:06:50 -05:00
|
|
|
|
2012-11-19 21:57:09 -05:00
|
|
|
def ==(other)
|
|
|
|
native == other.native
|
|
|
|
end
|
|
|
|
|
2015-08-09 12:55:56 -04:00
|
|
|
def path
|
2018-01-13 16:06:03 -05:00
|
|
|
path = find_xpath(XPath.ancestor_or_self).reverse
|
2015-08-09 12:55:56 -04:00
|
|
|
|
|
|
|
result = []
|
2018-06-12 16:06:25 -04:00
|
|
|
default_ns = path.last[:namespaceURI]
|
2017-11-13 16:04:47 -05:00
|
|
|
while (node = path.shift)
|
2015-08-09 12:55:56 -04:00
|
|
|
parent = path.first
|
2018-06-13 16:15:18 -04:00
|
|
|
selector = node[:tagName]
|
2018-06-12 16:06:25 -04:00
|
|
|
if node[:namespaceURI] != default_ns
|
|
|
|
selector = XPath.child.where((XPath.local_name == selector) & (XPath.namespace_uri == node[:namespaceURI])).to_s
|
|
|
|
selector
|
|
|
|
end
|
|
|
|
|
2015-08-09 12:55:56 -04:00
|
|
|
if parent
|
2018-05-08 19:44:57 -04:00
|
|
|
siblings = parent.find_xpath(selector)
|
2018-07-30 13:37:47 -04:00
|
|
|
selector += case siblings.size
|
2018-08-01 17:25:08 -04:00
|
|
|
when 0
|
|
|
|
'[ERROR]' # IE doesn't support full XPath (namespace-uri, etc)
|
|
|
|
when 1
|
|
|
|
'' # index not necessary when only one matching element
|
|
|
|
else
|
|
|
|
"[#{siblings.index(node) + 1}]"
|
|
|
|
end
|
2015-08-09 12:55:56 -04:00
|
|
|
end
|
2018-01-13 16:06:03 -05:00
|
|
|
result.push selector
|
2015-08-09 12:55:56 -04:00
|
|
|
end
|
|
|
|
|
2018-01-13 16:06:03 -05:00
|
|
|
'/' + result.reverse.join('/')
|
2015-08-09 12:55:56 -04:00
|
|
|
end
|
|
|
|
|
2018-08-31 17:24:30 -04:00
|
|
|
protected
|
|
|
|
|
|
|
|
def scroll_if_needed
|
|
|
|
yield
|
|
|
|
rescue ::Selenium::WebDriver::Error::MoveTargetOutOfBoundsError
|
|
|
|
scroll_to_center
|
|
|
|
yield
|
|
|
|
end
|
|
|
|
|
2011-04-11 01:24:00 -04:00
|
|
|
private
|
2018-01-09 17:05:50 -05:00
|
|
|
|
2018-01-13 16:06:03 -05:00
|
|
|
def boolean_attr(val)
|
2018-07-10 17:18:39 -04:00
|
|
|
val && (val != 'false')
|
2018-01-13 16:06:03 -05:00
|
|
|
end
|
|
|
|
|
2011-04-11 01:24:00 -04:00
|
|
|
# a reference to the select node if this is an option node
|
|
|
|
def select_node
|
2018-01-13 16:06:03 -05:00
|
|
|
find_xpath(XPath.ancestor(:select)[1]).first
|
2017-08-01 16:59:17 -04:00
|
|
|
end
|
|
|
|
|
2018-03-16 12:46:35 -04:00
|
|
|
def set_text(value, clear: nil, **_unused)
|
2018-08-17 16:57:12 -04:00
|
|
|
value = value.to_s
|
|
|
|
if value.empty? && clear.nil?
|
2017-08-01 16:59:17 -04:00
|
|
|
native.clear
|
2018-01-08 15:23:54 -05:00
|
|
|
elsif clear == :backspace
|
|
|
|
# Clear field by sending the correct number of backspace keys.
|
|
|
|
backspaces = [:backspace] * self.value.to_s.length
|
2018-08-17 16:57:12 -04:00
|
|
|
send_keys(*([:end] + backspaces + [value]))
|
2018-01-08 15:23:54 -05:00
|
|
|
elsif clear.is_a? Array
|
2018-08-17 16:57:12 -04:00
|
|
|
send_keys(*clear, value)
|
2017-08-01 16:59:17 -04:00
|
|
|
else
|
2018-01-08 15:23:54 -05:00
|
|
|
# Clear field by JavaScript assignment of the value property.
|
|
|
|
# Script can change a readonly element which user input cannot, so
|
|
|
|
# don't execute if readonly.
|
2018-08-24 07:45:19 -04:00
|
|
|
driver.execute_script "arguments[0].value = ''", self unless clear == :none
|
2018-08-17 16:57:12 -04:00
|
|
|
send_keys(value)
|
2017-08-01 16:59:17 -04:00
|
|
|
end
|
2011-04-11 01:24:00 -04:00
|
|
|
end
|
2017-11-16 21:32:26 -05:00
|
|
|
|
2018-09-01 14:20:11 -04:00
|
|
|
def click_with_options(click_options)
|
|
|
|
scroll_if_needed do
|
|
|
|
action_with_modifiers(click_options) do |action|
|
|
|
|
if block_given?
|
|
|
|
yield action
|
|
|
|
else
|
|
|
|
click_options.coords? ? action.click : action.click(native)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-15 12:17:09 -04:00
|
|
|
def scroll_to_center
|
2018-01-13 16:06:03 -05:00
|
|
|
script = <<-'JS'
|
2017-11-16 21:32:26 -05:00
|
|
|
try {
|
|
|
|
arguments[0].scrollIntoView({behavior: 'instant', block: 'center', inline: 'center'});
|
|
|
|
} catch(e) {
|
|
|
|
arguments[0].scrollIntoView(true);
|
|
|
|
}
|
|
|
|
JS
|
2018-05-15 12:17:09 -04:00
|
|
|
begin
|
|
|
|
driver.execute_script(script, self)
|
|
|
|
rescue StandardError # rubocop:disable Lint/HandleExceptions
|
|
|
|
# Swallow error if scrollIntoView with options isn't supported
|
|
|
|
end
|
2017-11-16 21:32:26 -05:00
|
|
|
end
|
2017-11-13 16:04:47 -05:00
|
|
|
|
2018-05-09 15:44:47 -04:00
|
|
|
def set_date(value) # rubocop:disable Naming/AccessorMethodName
|
2018-08-17 16:57:12 -04:00
|
|
|
value = SettableValue.new(value)
|
|
|
|
return set_text(value) unless value.dateable?
|
2018-05-09 15:44:47 -04:00
|
|
|
# TODO: this would be better if locale can be detected and correct keystrokes sent
|
2018-08-17 16:57:12 -04:00
|
|
|
update_value_js(value.to_date_str)
|
2018-03-09 17:23:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_time(value) # rubocop:disable Naming/AccessorMethodName
|
2018-08-17 16:57:12 -04:00
|
|
|
value = SettableValue.new(value)
|
|
|
|
return set_text(value) unless value.timeable?
|
2018-05-09 15:44:47 -04:00
|
|
|
# TODO: this would be better if locale can be detected and correct keystrokes sent
|
2018-08-17 16:57:12 -04:00
|
|
|
update_value_js(value.to_time_str)
|
2018-03-09 17:23:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_datetime_local(value) # rubocop:disable Naming/AccessorMethodName
|
2018-08-17 16:57:12 -04:00
|
|
|
value = SettableValue.new(value)
|
|
|
|
return set_text(value) unless value.timeable?
|
2018-05-09 15:44:47 -04:00
|
|
|
# TODO: this would be better if locale can be detected and correct keystrokes sent
|
2018-08-17 16:57:12 -04:00
|
|
|
update_value_js(value.to_datetime_str)
|
2018-05-09 15:44:47 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def update_value_js(value)
|
|
|
|
driver.execute_script(<<-JS, self, value)
|
|
|
|
if (document.activeElement !== arguments[0]){
|
|
|
|
arguments[0].focus();
|
|
|
|
}
|
|
|
|
if (arguments[0].value != arguments[1]) {
|
|
|
|
arguments[0].value = arguments[1]
|
|
|
|
arguments[0].dispatchEvent(new InputEvent('input'));
|
|
|
|
arguments[0].dispatchEvent(new Event('change', { bubbles: true }));
|
|
|
|
}
|
2018-06-06 19:11:47 -04:00
|
|
|
JS
|
2018-03-09 17:23:52 -05:00
|
|
|
end
|
|
|
|
|
2018-01-09 17:05:50 -05:00
|
|
|
def set_file(value) # rubocop:disable Naming/AccessorMethodName
|
2017-11-13 16:04:47 -05:00
|
|
|
path_names = value.to_s.empty? ? [] : value
|
2018-06-06 19:11:47 -04:00
|
|
|
native.send_keys(Array(path_names).join("\n"))
|
2017-11-13 16:04:47 -05:00
|
|
|
end
|
|
|
|
|
2018-01-09 17:05:50 -05:00
|
|
|
def set_content_editable(value) # rubocop:disable Naming/AccessorMethodName
|
|
|
|
# Ensure we are focused on the element
|
2017-11-13 16:04:47 -05:00
|
|
|
click
|
|
|
|
|
|
|
|
script = <<-JS
|
|
|
|
var range = document.createRange();
|
|
|
|
var sel = window.getSelection();
|
|
|
|
arguments[0].focus();
|
|
|
|
range.selectNodeContents(arguments[0]);
|
|
|
|
sel.removeAllRanges();
|
|
|
|
sel.addRange(range);
|
|
|
|
JS
|
|
|
|
driver.execute_script script, self
|
|
|
|
|
2018-01-03 19:03:10 -05:00
|
|
|
# The action api has a speed problem but both chrome and firefox 58 raise errors
|
|
|
|
# if we use the faster direct send_keys. For now just send_keys to the element
|
|
|
|
# we've already focused.
|
|
|
|
# native.send_keys(value.to_s)
|
2018-08-17 16:57:12 -04:00
|
|
|
browser_action.send_keys(value.to_s).perform
|
2017-11-13 16:04:47 -05:00
|
|
|
end
|
2017-12-29 15:37:08 -05:00
|
|
|
|
2018-08-17 16:57:12 -04:00
|
|
|
def action_with_modifiers(click_options)
|
|
|
|
actions = browser_action.move_to(native, *click_options.coords)
|
|
|
|
modifiers_down(actions, click_options.keys)
|
2017-12-29 15:37:08 -05:00
|
|
|
yield actions
|
2018-08-17 16:57:12 -04:00
|
|
|
modifiers_up(actions, click_options.keys)
|
2017-12-29 15:37:08 -05:00
|
|
|
actions.perform
|
|
|
|
ensure
|
2018-08-17 16:57:12 -04:00
|
|
|
act = browser_action
|
2018-08-20 19:46:31 -04:00
|
|
|
act.release_actions if act.respond_to?(:release_actions)
|
2017-12-29 15:37:08 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def modifiers_down(actions, keys)
|
2018-08-17 16:57:12 -04:00
|
|
|
each_key(keys) { |key| actions.key_down(key) }
|
2017-12-29 15:37:08 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def modifiers_up(actions, keys)
|
2018-08-17 16:57:12 -04:00
|
|
|
each_key(keys) { |key| actions.key_up(key) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def browser_action
|
|
|
|
driver.browser.action
|
|
|
|
end
|
|
|
|
|
|
|
|
def each_key(keys)
|
2017-12-29 15:37:08 -05:00
|
|
|
keys.each do |key|
|
|
|
|
key = case key
|
|
|
|
when :ctrl then :control
|
|
|
|
when :command, :cmd then :meta
|
|
|
|
else
|
|
|
|
key
|
|
|
|
end
|
2018-08-17 16:57:12 -04:00
|
|
|
yield key
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# SettableValue encapsulates time/date field formatting
|
|
|
|
class SettableValue
|
|
|
|
attr_reader :value
|
|
|
|
|
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
|
|
|
|
2018-09-21 14:43:15 -04:00
|
|
|
def to_s
|
|
|
|
value.to_s
|
|
|
|
end
|
|
|
|
|
2018-08-17 16:57:12 -04:00
|
|
|
def dateable?
|
|
|
|
!value.is_a?(String) && value.respond_to?(:to_date)
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_date_str
|
|
|
|
value.to_date.strftime('%Y-%m-%d')
|
|
|
|
end
|
|
|
|
|
|
|
|
def timeable?
|
|
|
|
!value.is_a?(String) && value.respond_to?(:to_time)
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_time_str
|
|
|
|
value.to_time.strftime('%H:%M')
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_datetime_str
|
|
|
|
value.to_time.strftime('%Y-%m-%dT%H:%M')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
private_constant :SettableValue
|
|
|
|
|
|
|
|
# ClickOptions encapsulates click option logic
|
|
|
|
class ClickOptions
|
|
|
|
attr_reader :keys, :options
|
|
|
|
|
|
|
|
def initialize(keys, options)
|
|
|
|
@keys = keys
|
|
|
|
@options = options
|
|
|
|
end
|
|
|
|
|
|
|
|
def coords?
|
|
|
|
options[:x] && options[:y]
|
|
|
|
end
|
|
|
|
|
|
|
|
def coords
|
|
|
|
[options[:x], options[:y]]
|
|
|
|
end
|
|
|
|
|
|
|
|
def empty?
|
|
|
|
keys.empty? && !coords?
|
2017-12-29 15:37:08 -05:00
|
|
|
end
|
|
|
|
end
|
2018-08-17 16:57:12 -04:00
|
|
|
private_constant :ClickOptions
|
2011-04-11 01:24:00 -04:00
|
|
|
end
|