Class: Applitools::Selenium::Target
- Inherits:
-
Object
- Object
- Applitools::Selenium::Target
- Includes:
- FluentInterface
- Defined in:
- lib/applitools/selenium/target.rb
Instance Attribute Summary collapse
-
#coordinate_type ⇒ Object
Returns the value of attribute coordinate_type.
-
#element ⇒ Object
Returns the value of attribute element.
-
#floating_regions ⇒ Object
Returns the value of attribute floating_regions.
-
#frames ⇒ Object
Returns the value of attribute frames.
-
#ignored_regions ⇒ Object
Returns the value of attribute ignored_regions.
-
#options ⇒ Object
Returns the value of attribute options.
-
#region_to_check ⇒ Object
Returns the value of attribute region_to_check.
Class Method Summary collapse
Instance Method Summary collapse
-
#floating(region_or_element, bounds, left, top, right, bottom, padding) ⇒ Object
Sets the wanted floating region.
- #frame(element) ⇒ Object
- #fully ⇒ Object
-
#ignore(region_or_element, how, what, padding = Applitools::PaddingBounds::PIXEL_PADDING) ⇒ Object
Add the wanted ignored regions.
-
#initialize ⇒ Target
constructor
Initialize a Applitools::Selenium::Target instance.
-
#region(element, how, what) ⇒ Applitools::Selenium::Target
Add the desired region.
Constructor Details
#initialize ⇒ Target
Initialize a Applitools::Selenium::Target instance.
22 23 24 25 26 27 28 29 |
# File 'lib/applitools/selenium/target.rb', line 22 def initialize self.frames = [] self. = { ignore_caret: false, ignore_mismatch: false } reset_for_fullscreen end |
Instance Attribute Details
#coordinate_type ⇒ Object
Returns the value of attribute coordinate_type.
19 20 21 |
# File 'lib/applitools/selenium/target.rb', line 19 def coordinate_type @coordinate_type end |
#element ⇒ Object
Returns the value of attribute element.
19 20 21 |
# File 'lib/applitools/selenium/target.rb', line 19 def element @element end |
#floating_regions ⇒ Object
Returns the value of attribute floating_regions.
19 20 21 |
# File 'lib/applitools/selenium/target.rb', line 19 def floating_regions @floating_regions end |
#frames ⇒ Object
Returns the value of attribute frames.
19 20 21 |
# File 'lib/applitools/selenium/target.rb', line 19 def frames @frames end |
#ignored_regions ⇒ Object
Returns the value of attribute ignored_regions.
19 20 21 |
# File 'lib/applitools/selenium/target.rb', line 19 def ignored_regions @ignored_regions end |
#options ⇒ Object
Returns the value of attribute options.
19 20 21 |
# File 'lib/applitools/selenium/target.rb', line 19 def @options end |
#region_to_check ⇒ Object
Returns the value of attribute region_to_check.
19 20 21 |
# File 'lib/applitools/selenium/target.rb', line 19 def region_to_check @region_to_check end |
Class Method Details
.frame(element) ⇒ Object
6 7 8 |
# File 'lib/applitools/selenium/target.rb', line 6 def frame(element) new.frame(element) end |
.region(element) ⇒ Object
14 15 16 |
# File 'lib/applitools/selenium/target.rb', line 14 def region(element) new.region(element) end |
.window ⇒ Object
10 11 12 |
# File 'lib/applitools/selenium/target.rb', line 10 def window new end |
Instance Method Details
#floating(region_or_element, bounds, left, top, right, bottom, padding) ⇒ Object
Sets the wanted floating region
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/applitools/selenium/target.rb', line 93 def floating(*args) requested_padding = if args.last.is_a? Applitools::PaddingBounds args.pop else Applitools::PaddingBounds::PIXEL_PADDING end value = case args.first when Applitools::FloatingRegion proc { args.first.padding(requested_padding) } when ::Selenium::WebDriver::Element, Applitools::Selenium::Element, ::Applitools::Region proc { Applitools::FloatingRegion.any(args.shift, *args).padding(requested_padding) } else proc do |driver| Applitools::FloatingRegion.any( driver.find_element(args.shift, args.shift), *args ).padding(requested_padding) end end floating_regions << value self end |
#frame(element) ⇒ Object
120 121 122 123 124 |
# File 'lib/applitools/selenium/target.rb', line 120 def frame(element) frames << element reset_for_fullscreen self end |
#fully ⇒ Object
115 116 117 118 |
# File 'lib/applitools/selenium/target.rb', line 115 def fully [:stitch_content] = true self end |
#ignore(region_or_element, how, what, padding = Applitools::PaddingBounds::PIXEL_PADDING) ⇒ Object
Add the wanted ignored regions.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/applitools/selenium/target.rb', line 38 def ignore(*args) if args.empty? reset_ignore else requested_padding = if args.last.is_a? Applitools::PaddingBounds args.pop else Applitools::PaddingBounds::PIXEL_PADDING end ignored_regions << case args.first when Applitools::Region proc { args.first.padding(requested_padding) } when Applitools::Selenium::Element, ::Selenium::WebDriver::Element proc do region = args.first Applitools::Region.from_location_size( region.location, region.size ).padding(requested_padding) end else proc do |driver| region = driver.find_element(*args) Applitools::Region.from_location_size( region.location, region.size ).padding(requested_padding) end end end self end |
#region(element, how, what) ⇒ Applitools::Selenium::Target
Add the desired region.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/applitools/selenium/target.rb', line 137 def region(*args) self.region_to_check = case args.first when Applitools::Selenium::Element, Applitools::Region, ::Selenium::WebDriver::Element proc { args.first } else proc do |driver| driver.find_element(*args) end end self.coordinate_type = Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative] [:timeout] = nil reset_ignore reset_floating self end |