Class: Applitools::Selenium::EyesScreenshot
- Inherits:
-
EyesScreenshot
- Object
- EyesScreenshot
- Applitools::Selenium::EyesScreenshot
- Defined in:
- lib/applitools/selenium/eyes_screenshot.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#driver ⇒ Object
Returns the value of attribute driver.
-
#region_provider ⇒ Object
Returns the value of attribute region_provider.
Instance Method Summary collapse
- #convert_location(location, _from, _to) ⇒ Object
-
#initialize(image, options = {}) ⇒ EyesScreenshot
constructor
A new instance of EyesScreenshot.
- #intersected_region(region, original_coordinate_types, result_coordinate_types) ⇒ Object
-
#location_in_screenshot(location, coordinate_type) ⇒ Applitools::Location
Returns the location in the screenshot.
Constructor Details
#initialize(image, options = {}) ⇒ EyesScreenshot
Returns a new instance of EyesScreenshot.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/applitools/selenium/eyes_screenshot.rb', line 9 def initialize(image, = {}) super image self.region_provider = [:region_provider] if [:region_provider] Applitools::ArgumentGuard.is_a?( region_provider, 'options[:region_provider]', Applitools::Selenium::RegionProvider ) self.driver = region_provider.driver end |
Instance Attribute Details
#driver ⇒ Object
Returns the value of attribute driver.
6 7 8 |
# File 'lib/applitools/selenium/eyes_screenshot.rb', line 6 def driver @driver end |
#region_provider ⇒ Object
Returns the value of attribute region_provider.
6 7 8 |
# File 'lib/applitools/selenium/eyes_screenshot.rb', line 6 def region_provider @region_provider end |
Instance Method Details
#convert_location(location, _from, _to) ⇒ Object
20 21 22 |
# File 'lib/applitools/selenium/eyes_screenshot.rb', line 20 def convert_location(location, _from, _to) location.offset_negative(top_left_location) end |
#intersected_region(region, original_coordinate_types, result_coordinate_types) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/applitools/selenium/eyes_screenshot.rb', line 44 def intersected_region(region, original_coordinate_types, result_coordinate_types) raise Applitools::Selenium::UnsupportedCoordinateType, original_coordinate_types unless original_coordinate_types == Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative] raise Applitools::Selenium::UnsupportedCoordinateType, result_coordinate_types unless result_coordinate_types == Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is] return Applitools::Region::EMPTY if region.empty? intersected_region = convert_region_location( region, original_coordinate_types, Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is] ) intersected_region.intersect(image_region) end |
#location_in_screenshot(location, coordinate_type) ⇒ Applitools::Location
Returns the location in the screenshot.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/applitools/selenium/eyes_screenshot.rb', line 29 def location_in_screenshot(location, coordinate_type) raise Applitools::Selenium::UnsupportedCoordinateType, coordinate_type unless coordinate_type == Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative] location = convert_location( location, coordinate_type, Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is] ) unless image_region.contains?(location.x, location.y) raise Applitools::OutOfBoundsException, "Location #{location} (#{coordinate_type}) is not visible in screenshot!" end location end |