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
- #finalize ⇒ Object
-
#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.
- #send_dom(value = true) ⇒ Object
- #use_dom(value = true) ⇒ Object
Constructor Details
#initialize ⇒ Target
Initialize a Applitools::Selenium::Target instance.
27 28 29 30 31 32 33 34 35 |
# File 'lib/applitools/selenium/target.rb', line 27 def initialize self.frames = [] self. = { ignore_caret: true, ignore_mismatch: false, send_dom: nil } reset_for_fullscreen end |
Instance Attribute Details
#coordinate_type ⇒ Object
Returns the value of attribute coordinate_type.
21 22 23 |
# File 'lib/applitools/selenium/target.rb', line 21 def coordinate_type @coordinate_type end |
#element ⇒ Object
Returns the value of attribute element.
21 22 23 |
# File 'lib/applitools/selenium/target.rb', line 21 def element @element end |
#floating_regions ⇒ Object
Returns the value of attribute floating_regions.
21 22 23 |
# File 'lib/applitools/selenium/target.rb', line 21 def floating_regions @floating_regions end |
#frames ⇒ Object
Returns the value of attribute frames.
21 22 23 |
# File 'lib/applitools/selenium/target.rb', line 21 def frames @frames end |
#ignored_regions ⇒ Object
Returns the value of attribute ignored_regions.
21 22 23 |
# File 'lib/applitools/selenium/target.rb', line 21 def ignored_regions @ignored_regions end |
#options ⇒ Object
Returns the value of attribute options.
21 22 23 |
# File 'lib/applitools/selenium/target.rb', line 21 def @options end |
#region_to_check ⇒ Object
Returns the value of attribute region_to_check.
21 22 23 |
# File 'lib/applitools/selenium/target.rb', line 21 def region_to_check @region_to_check end |
Class Method Details
.frame(element) ⇒ Object
8 9 10 |
# File 'lib/applitools/selenium/target.rb', line 8 def frame(element) new.frame(element) end |
.region(*args) ⇒ Object
16 17 18 |
# File 'lib/applitools/selenium/target.rb', line 16 def region(*args) new.region(*args) end |
.window ⇒ Object
12 13 14 |
# File 'lib/applitools/selenium/target.rb', line 12 def window new end |
Instance Method Details
#finalize ⇒ Object
176 177 178 179 180 181 |
# File 'lib/applitools/selenium/target.rb', line 176 def finalize return self unless frame_or_element region = frame_or_element self.frame_or_element = nil dup.region(region) end |
#floating(region_or_element, bounds, left, top, right, bottom, padding) ⇒ Object
Sets the wanted floating region
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/applitools/selenium/target.rb', line 99 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
127 128 129 130 131 132 |
# File 'lib/applitools/selenium/target.rb', line 127 def frame(element) frames << frame_or_element if frame_or_element self.frame_or_element = element reset_for_fullscreen self end |
#fully ⇒ Object
121 122 123 124 125 |
# File 'lib/applitools/selenium/target.rb', line 121 def fully [:stitch_content] = true handle_frames self end |
#ignore(region_or_element, how, what, padding = Applitools::PaddingBounds::PIXEL_PADDING) ⇒ Object
Add the wanted ignored regions.
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 69 70 71 72 73 74 |
# File 'lib/applitools/selenium/target.rb', line 44 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.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/applitools/selenium/target.rb', line 145 def region(*args) handle_frames self.region_to_check = case args.first when Applitools::Selenium::Element, Applitools::Region, ::Selenium::WebDriver::Element proc { args.first } when String proc do |driver| driver.find_element(name_or_id: args.first) end 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 |
#send_dom(value = true) ⇒ Object
166 167 168 169 |
# File 'lib/applitools/selenium/target.rb', line 166 def send_dom(value = true) [:send_dom] = value ? true : false self end |
#use_dom(value = true) ⇒ Object
171 172 173 174 |
# File 'lib/applitools/selenium/target.rb', line 171 def use_dom(value = true) [:use_dom] = value ? true : false self end |