Class: Applitools::Selenium::RegionProvider
- Inherits:
-
Object
- Object
- Applitools::Selenium::RegionProvider
- Defined in:
- lib/applitools/selenium/region_provider.rb
Defined Under Namespace
Modules: FirefoxFrameWindowCalculator, FrameWindowCalculator
Constant Summary collapse
- FF_OLD_VERSION =
'45.0'
Instance Attribute Summary collapse
-
#driver ⇒ Object
Returns the value of attribute driver.
-
#eye_region ⇒ Object
Returns the value of attribute eye_region.
-
#scroll_position_provider ⇒ Object
Returns the value of attribute scroll_position_provider.
Instance Method Summary collapse
- #calculate_frame_window ⇒ Object
- #coordinate_type ⇒ Object
-
#initialize(driver, eye_region) ⇒ RegionProvider
constructor
A new instance of RegionProvider.
- #region(include_borders = true) ⇒ Object
Constructor Details
#initialize(driver, eye_region) ⇒ RegionProvider
Returns a new instance of RegionProvider.
10 11 12 13 14 |
# File 'lib/applitools/selenium/region_provider.rb', line 10 def initialize(driver, eye_region) self.driver = driver self.eye_region = eye_region self.scroll_position_provider = Applitools::Selenium::ScrollPositionProvider.new driver end |
Instance Attribute Details
#driver ⇒ Object
Returns the value of attribute driver.
8 9 10 |
# File 'lib/applitools/selenium/region_provider.rb', line 8 def driver @driver end |
#eye_region ⇒ Object
Returns the value of attribute eye_region.
8 9 10 |
# File 'lib/applitools/selenium/region_provider.rb', line 8 def eye_region @eye_region end |
#scroll_position_provider ⇒ Object
Returns the value of attribute scroll_position_provider.
8 9 10 |
# File 'lib/applitools/selenium/region_provider.rb', line 8 def scroll_position_provider @scroll_position_provider end |
Instance Method Details
#calculate_frame_window ⇒ Object
46 47 48 49 |
# File 'lib/applitools/selenium/region_provider.rb', line 46 def calculate_frame_window return Applitools::Region::EMPTY unless inside_a_frame? frame_window_calculator.frame_window(driver.frame_chain) end |
#coordinate_type ⇒ Object
42 43 44 |
# File 'lib/applitools/selenium/region_provider.rb', line 42 def coordinate_type nil end |
#region(include_borders = true) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/applitools/selenium/region_provider.rb', line 16 def region(include_borders = true) region = if include_borders location = eye_region.location.offset_negative( Applitools::Location.new(eye_region.padding_left, eye_region.padding_top) ) size = eye_region.size.tap do |s| s.width += eye_region.padding_left + eye_region.padding_right s.height += eye_region.padding_top + eye_region.padding_bottom end Applitools::Region.from_location_size(location, size) else Applitools::Region.from_location_size(eye_region.location, eye_region.size) end if inside_a_frame? frame_window = calculate_frame_window return frame_window if eye_region.is_a?(Applitools::Region) && eye_region.empty? region.location = region.location.offset(frame_window.location) region.intersect(frame_window) unless frame_window.empty? # exception if empty else region.location = region.location.offset_negative scroll_position_provider.current_position end return eye_region if eye_region.is_a?(Applitools::Region) && eye_region.empty? region end |