class Applitools::Selenium::Element
Constants
- JS_GET_COMPUTED_STYLE_FORMATTED_STR
- JS_GET_OVERFLOW
- JS_GET_SCROLL_HEIGHT
- JS_GET_SCROLL_LEFT
- JS_GET_SCROLL_TOP
- JS_GET_SCROLL_WIDTH
- JS_SCROLL_TO_FORMATTED_STR
- JS_SET_OVERFLOW_DATA_FORMATTED_STR
- JS_SET_OVERFLOW_FORMATTED_STR
- JS_SET_SCROLL_DATA_FORMATTED_STR
- TRACE_PREFIX
Attributes
Public Class Methods
Source
# File lib/applitools/selenium/element.rb, line 50 def initialize(driver, element) super(element) @driver = driver end
Initialize class instance.
@param [Applitools::Selenium::Driver] driver The wrapped Selenium
driver instance. @param [Applitools::Selenium::Element] element The wrapped Selenium
element instance.
Calls superclass method
Public Instance Methods
Source
# File lib/applitools/selenium/element.rb, line 72 def ==(other) if other.is_a? self.class super other.web_element else super other end end
Calls superclass method
Also aliased as: eql?
Source
# File lib/applitools/selenium/element.rb, line 169 def border_bottom_width computed_style_integer(:'border-bottom-width') end
Source
# File lib/applitools/selenium/element.rb, line 157 def border_left_width computed_style_integer(:'border-left-width') end
Source
# File lib/applitools/selenium/element.rb, line 165 def border_right_width computed_style_integer(:'border-right-width') end
Source
# File lib/applitools/selenium/element.rb, line 161 def border_top_width computed_style_integer(:'border-top-width') end
Source
# File lib/applitools/selenium/element.rb, line 96 def bounds point = location left = point.x top = point.y width = 0 height = 0 begin dimension = size width = dimension.width height = dimension.height rescue => e # Not supported on all platforms. Applitools::EyesLogger.error("Failed extracting size using JavaScript: (#{e.message})") end if left < 0 width = [0, width + left].max left = 0 end if top < 0 height = [0, height + top].max top = 0 end Applitools::Region.new(left, top, width, height) end
Gets the bounds of the element.
@return [Applitools::Base::Region] An instance of the region.
Source
# File lib/applitools/selenium/element.rb, line 62 def click @driver.add_mouse_trigger(Applitools::MouseTrigger::MOUSE_ACTION[:click], self) # logger.info "click(#{bounds})"; web_element.click end
Source
# File lib/applitools/selenium/element.rb, line 149 def computed_style(prop_style) driver.execute_script(JS_GET_COMPUTED_STYLE_FORMATTED_STR % prop_style, self).to_s end
Source
# File lib/applitools/selenium/element.rb, line 153 def computed_style_integer(prop_style) computed_style(prop_style).gsub(/px/, '').to_i.round end
Source
# File lib/applitools/selenium/element.rb, line 125 def find_element(*args) self.class.new driver, super end
Calls superclass method
Source
# File lib/applitools/selenium/element.rb, line 129 def find_elements(*args) super(*args).map { |e| self.class.new driver, e } end
Calls superclass method
Source
# File lib/applitools/selenium/element.rb, line 68 def inspect TRACE_PREFIX + web_element.inspect end
Source
# File lib/applitools/selenium/element.rb, line 133 def overflow driver.execute_script(JS_GET_OVERFLOW, __getobj__).to_s end
Source
# File lib/applitools/selenium/element.rb, line 137 def overflow=(overflow) driver.execute_script(JS_SET_OVERFLOW_FORMATTED_STR % overflow, self) end
Source
# File lib/applitools/selenium/element.rb, line 145 def overflow_data_attribute=(value) driver.execute_script(JS_SET_OVERFLOW_DATA_FORMATTED_STR % value, self) end
Source
# File lib/applitools/selenium/element.rb, line 185 def padding_bottom_width computed_style_integer(:'padding-bottom') end
Source
# File lib/applitools/selenium/element.rb, line 173 def padding_left_width computed_style_integer(:'padding-left') end
Source
# File lib/applitools/selenium/element.rb, line 177 def padding_right_width computed_style_integer(:'padding-right') end
Source
# File lib/applitools/selenium/element.rb, line 181 def padding_top_width computed_style_integer(:'padding-top') end
Source
# File lib/applitools/selenium/element.rb, line 141 def scroll_data_attribute=(value) driver.execute_script(JS_SET_SCROLL_DATA_FORMATTED_STR % value, self) end
Source
# File lib/applitools/selenium/element.rb, line 201 def scroll_height Integer driver.execute_script(JS_GET_SCROLL_HEIGHT, self).to_s end
Source
# File lib/applitools/selenium/element.rb, line 189 def scroll_left Integer driver.execute_script(JS_GET_SCROLL_LEFT, self).to_s end
Source
# File lib/applitools/selenium/element.rb, line 205 def scroll_to(location) driver.execute_script format(JS_SCROLL_TO_FORMATTED_STR, location.x, location.y), self end
Source
# File lib/applitools/selenium/element.rb, line 193 def scroll_top Integer driver.execute_script(JS_GET_SCROLL_TOP, self).to_s end
Source
# File lib/applitools/selenium/element.rb, line 197 def scroll_width Integer driver.execute_script(JS_GET_SCROLL_WIDTH, self).to_s end
Source
# File lib/applitools/selenium/element.rb, line 85 def send_keys(*args) Selenium::WebDriver::Keys.encode(args).each do |key| @driver.add_text_trigger(self, key.to_s) end web_element.send_keys(*args) end
Types content into text box. @param [Array, String] keys The content to type. @!parse def send_keys
(keys); end;
Also aliased as: send_key
Source
# File lib/applitools/selenium/element.rb, line 209 def to_hash { left: location.x.to_i, top: location.y.to_i, width: size.width.to_i, height: size.height.to_i } end
Protected Instance Methods
Source
# File lib/applitools/selenium/element.rb, line 56 def web_element @web_element ||= __getobj__ end