2016-03-07 16:52:19 -08:00
|
|
|
# frozen_string_literal: true
|
2018-01-08 12:23:54 -08:00
|
|
|
|
2010-07-09 20:08:33 +02:00
|
|
|
module Capybara
|
|
|
|
module Driver
|
|
|
|
class Node
|
2019-01-08 15:51:05 -08:00
|
|
|
attr_reader :driver, :native, :initial_cache
|
2010-07-09 20:08:33 +02:00
|
|
|
|
2019-01-08 15:51:05 -08:00
|
|
|
def initialize(driver, native, initial_cache = {})
|
2010-07-09 20:08:33 +02:00
|
|
|
@driver = driver
|
2010-07-15 20:55:12 +02:00
|
|
|
@native = native
|
2019-01-08 15:51:05 -08:00
|
|
|
@initial_cache = initial_cache
|
2010-07-09 20:08:33 +02:00
|
|
|
end
|
|
|
|
|
2013-02-17 14:46:37 +01:00
|
|
|
def all_text
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def visible_text
|
2010-07-09 20:08:33 +02:00
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def [](name)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def value
|
2010-07-10 03:11:54 +02:00
|
|
|
raise NotImplementedError
|
2010-07-09 20:08:33 +02:00
|
|
|
end
|
|
|
|
|
2018-06-19 13:34:54 -07:00
|
|
|
def style(styles)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2012-09-17 14:48:13 +02:00
|
|
|
# @param value String or Array. Array is only allowed if node has 'multiple' attribute
|
2014-06-18 16:36:11 -07:00
|
|
|
# @param options [Hash{}] Driver specific options for how to set a value on a node
|
2016-08-17 16:14:39 -07:00
|
|
|
def set(value, **options)
|
2010-07-09 20:08:33 +02:00
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2010-08-14 13:42:53 +02:00
|
|
|
def select_option
|
2010-07-09 20:08:33 +02:00
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2010-08-14 13:42:53 +02:00
|
|
|
def unselect_option
|
2010-07-09 20:08:33 +02:00
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2018-05-17 14:45:53 -07:00
|
|
|
def click(keys = [], **options)
|
2010-07-09 20:08:33 +02:00
|
|
|
raise NotImplementedError
|
|
|
|
end
|
2016-06-11 12:09:23 -07:00
|
|
|
|
2018-05-17 14:45:53 -07:00
|
|
|
def right_click(keys = [], **options)
|
2014-06-29 19:28:54 -03:00
|
|
|
raise NotImplementedError
|
2013-05-10 09:55:17 -07:00
|
|
|
end
|
2016-06-11 12:09:23 -07:00
|
|
|
|
2018-05-17 14:45:53 -07:00
|
|
|
def double_click(keys = [], **options)
|
2013-05-10 09:55:17 -07:00
|
|
|
raise NotImplementedError
|
|
|
|
end
|
2016-06-11 12:09:23 -07:00
|
|
|
|
2015-01-23 12:23:57 -08:00
|
|
|
def send_keys(*args)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
2016-06-11 12:09:23 -07:00
|
|
|
|
2013-02-25 10:37:25 -08:00
|
|
|
def hover
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
2016-06-11 12:09:23 -07:00
|
|
|
|
2010-07-09 20:08:33 +02:00
|
|
|
def drag_to(element)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2018-12-17 10:09:53 -08:00
|
|
|
def scroll_by(x, y)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def scroll_to(element, location = :top)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2010-07-09 20:08:33 +02:00
|
|
|
def tag_name
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def visible?
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2010-12-23 10:38:44 -08:00
|
|
|
def checked?
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def selected?
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2013-01-29 09:46:56 +00:00
|
|
|
def disabled?
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2016-06-11 12:09:23 -07:00
|
|
|
def readonly?
|
|
|
|
!!self[:readonly]
|
|
|
|
end
|
|
|
|
|
|
|
|
def multiple?
|
|
|
|
!!self[:multiple]
|
|
|
|
end
|
|
|
|
|
2010-07-09 20:08:33 +02:00
|
|
|
def path
|
2013-03-09 11:50:27 +08:00
|
|
|
raise NotSupportedByDriverError, 'Capybara::Driver::Node#path'
|
2010-07-09 20:08:33 +02:00
|
|
|
end
|
2013-02-17 14:46:37 +01:00
|
|
|
|
2010-07-09 20:08:33 +02:00
|
|
|
def trigger(event)
|
2013-03-09 11:50:27 +08:00
|
|
|
raise NotSupportedByDriverError, 'Capybara::Driver::Node#trigger'
|
2010-07-09 20:08:33 +02:00
|
|
|
end
|
2010-07-10 16:34:33 +02:00
|
|
|
|
|
|
|
def inspect
|
2012-06-21 14:26:33 +03:00
|
|
|
%(#<#{self.class} tag="#{tag_name}" path="#{path}">)
|
2014-04-22 12:06:34 -04:00
|
|
|
rescue NotSupportedByDriverError
|
2012-06-21 14:26:33 +03:00
|
|
|
%(#<#{self.class} tag="#{tag_name}">)
|
2010-07-10 16:34:33 +02:00
|
|
|
end
|
2012-11-19 21:57:09 -05:00
|
|
|
|
|
|
|
def ==(other)
|
2013-03-09 11:50:27 +08:00
|
|
|
raise NotSupportedByDriverError, 'Capybara::Driver::Node#=='
|
2012-11-19 21:57:09 -05:00
|
|
|
end
|
2010-07-09 20:08:33 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|