class Applitools::Selenium::CssTranslateElementPositionProvider

@!visibility private

Public Instance Methods

current_position() click to toggle source

Gets the current position.

@return [Applitools::Location] The location.

Calls superclass method
# File lib/applitools/selenium/css_translate_element_position_provider.rb, line 14
def current_position
  position = super.offset_negative transforms_offset
  logger.info "Current position is #{position}"
  position
end
position=(location) click to toggle source
Calls superclass method
# File lib/applitools/selenium/css_translate_element_position_provider.rb, line 20
def position=(location)
  super
  out_of_eyes = location.dup.offset_negative(current_position)
  return if out_of_eyes == Applitools::Location::TOP_LEFT
  logger.info "Moving element by #{out_of_eyes} to fit in the eyes region"

  Applitools::Utils::EyesSeleniumUtils.element_translate_to(
    driver,
    element,
    transforms_offset.offset_negative(out_of_eyes)
  )
  logger.info 'Done scrolling element!'
end
Also aliased as: scroll_to
scroll_to(location)
Alias for: position=

Private Instance Methods

transforms_offset() click to toggle source
# File lib/applitools/selenium/css_translate_element_position_provider.rb, line 38
def transforms_offset
  logger.info 'Getting element transforms...'
  transforms = Applitools::Utils::EyesSeleniumUtils.current_element_transforms(driver, element)
  logger.info "Current transforms: #{transforms}"
  transform_positions = transforms.values.compact.select { |s| !s.empty? }
                                  .map { |s| get_position_from_transform(s) }
  transform_positions.each do |p|
    raise Applitools::EyesError.new 'Got different css positions!' unless p == transform_positions[0]
  end
  transform_positions[0] || Applitools::Location::TOP_LEFT.dup
end