Class: Applitools::Element
- Inherits:
-
Object
- Object
- Applitools::Element
- Defined in:
- lib/eyes_selenium_ruby/eyes/element.rb
Constant Summary collapse
- ELEMENT_METHODS =
[ :hash, :id, :id=, :bridge=, :submit, :clear, :tag_name, :attribute, :selected?, :enabled?, :displayed?, :text, :css_value, :find_element, :find_elements, :location, :size, :location_once_scrolled_into_view, :ref, :to_json, :as_json ]
Instance Attribute Summary collapse
-
#driver ⇒ Object
Returns the value of attribute driver.
-
#web_element ⇒ Object
Returns the value of attribute web_element.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #click ⇒ Object
-
#initialize(driver, element) ⇒ Element
constructor
A new instance of Element.
- #inspect ⇒ Object
- #region ⇒ Object
- #send_keys(*args) ⇒ Object (also: #send_key)
Constructor Details
#initialize(driver, element) ⇒ Element
Returns a new instance of Element.
23 24 25 26 |
# File 'lib/eyes_selenium_ruby/eyes/element.rb', line 23 def initialize(driver, element) @driver = driver @web_element = element end |
Instance Attribute Details
#driver ⇒ Object
Returns the value of attribute driver.
2 3 4 |
# File 'lib/eyes_selenium_ruby/eyes/element.rb', line 2 def driver @driver end |
#web_element ⇒ Object
Returns the value of attribute web_element.
2 3 4 |
# File 'lib/eyes_selenium_ruby/eyes/element.rb', line 2 def web_element @web_element end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
40 41 42 |
# File 'lib/eyes_selenium_ruby/eyes/element.rb', line 40 def ==(other) other.kind_of?(web_element.class) && web_element == other end |
#click ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/eyes_selenium_ruby/eyes/element.rb', line 28 def click current_control = region offset = current_control.middle_offset driver.user_inputs << Applitools::MouseTrigger.new(:click, current_control, offset) web_element.click end |
#inspect ⇒ Object
36 37 38 |
# File 'lib/eyes_selenium_ruby/eyes/element.rb', line 36 def inspect "EyesWebElement" + web_element.inspect end |
#region ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/eyes_selenium_ruby/eyes/element.rb', line 55 def region point = location left, top, width, height = point.x, point.y, 0, 0 begin dimension = size width, height = dimension.width, dimension.height rescue # Not supported on all platforms. end if left < 0 width = [0, width + left].max left = 0 end if top < 0 height = [0, height + top].max top = 0 end return Applitools::Region.new(left, top, width, height) end |
#send_keys(*args) ⇒ Object Also known as: send_key
45 46 47 48 49 50 51 52 |
# File 'lib/eyes_selenium_ruby/eyes/element.rb', line 45 def send_keys(*args) current_control = region Selenium::WebDriver::Keys.encode(args).each do |key| driver.user_inputs << Applitools::TextTrigger.new(key.to_s, current_control) end web_element.send_keys(args) end |