Class: Applitools::Selenium::MoveToRegionVisibilityStrategy
- Inherits:
-
Object
- Object
- Applitools::Selenium::MoveToRegionVisibilityStrategy
- Extended by:
- Forwardable
- Defined in:
- lib/applitools/selenium/move_to_region_visibility_strategy.rb
Constant Summary collapse
- VISIBILITY_OFFSET =
100
Instance Attribute Summary collapse
-
#original_position ⇒ Object
Returns the value of attribute original_position.
Instance Method Summary collapse
-
#move_to_region(position_provider, location) ⇒ Object
Set the location of the position provider.
-
#return_to_original_position(position_provider) ⇒ Object
Returns the position provider to its original position.
Instance Attribute Details
#original_position ⇒ Object
Returns the value of attribute original_position.
10 11 12 |
# File 'lib/applitools/selenium/move_to_region_visibility_strategy.rb', line 10 def original_position @original_position end |
Instance Method Details
#move_to_region(position_provider, location) ⇒ Object
Set the location of the position provider.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/applitools/selenium/move_to_region_visibility_strategy.rb', line 18 def move_to_region(position_provider, location) logger.info 'Getting current position state...' self.original_position = position_provider.state dst_x = location.x - VISIBILITY_OFFSET dst_y = location.y - VISIBILITY_OFFSET dst_x = 0 if dst_x < 0 dst_y = 0 if dst_y < 0 logger.info "Done! Setting position to #{location}..." position_provider.position = Applitools::Location.new(dst_x, dst_y) logger.info 'Done!' end |
#return_to_original_position(position_provider) ⇒ Object
Returns the position provider to its original position.
38 39 40 41 42 43 |
# File 'lib/applitools/selenium/move_to_region_visibility_strategy.rb', line 38 def return_to_original_position(position_provider) return if original_position.nil? logger.info 'Returning to original position...' position_provider.restore_state original_position logger.info 'Done!' end |