Class: Applitools::Selenium::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/applitools/selenium/target.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTarget

Initialize a Applitools::Selenium::Target instance.



17
18
19
20
21
# File 'lib/applitools/selenium/target.rb', line 17

def initialize
  self.frames = []
  self.options = {}
  reset_for_fullscreen
end

Instance Attribute Details

#coordinate_typeObject

Returns the value of attribute coordinate_type.



14
15
16
# File 'lib/applitools/selenium/target.rb', line 14

def coordinate_type
  @coordinate_type
end

#elementObject

Returns the value of attribute element.



14
15
16
# File 'lib/applitools/selenium/target.rb', line 14

def element
  @element
end

#framesObject

Returns the value of attribute frames.



14
15
16
# File 'lib/applitools/selenium/target.rb', line 14

def frames
  @frames
end

#ignored_regionsObject

Returns the value of attribute ignored_regions.



14
15
16
# File 'lib/applitools/selenium/target.rb', line 14

def ignored_regions
  @ignored_regions
end

#optionsObject

Returns the value of attribute options.



14
15
16
# File 'lib/applitools/selenium/target.rb', line 14

def options
  @options
end

#region_to_checkObject

Returns the value of attribute region_to_check.



14
15
16
# File 'lib/applitools/selenium/target.rb', line 14

def region_to_check
  @region_to_check
end

Class Method Details

.region(element) ⇒ Object



9
10
11
# File 'lib/applitools/selenium/target.rb', line 9

def region(element)
  new.region(element)
end

.windowObject



5
6
7
# File 'lib/applitools/selenium/target.rb', line 5

def window
  new
end

Instance Method Details

#float(*_) ⇒ Object



45
46
47
# File 'lib/applitools/selenium/target.rb', line 45

def float(*_)
  self
end

#frame(element) ⇒ Object



59
60
61
62
63
# File 'lib/applitools/selenium/target.rb', line 59

def frame(element)
  frames << element
  reset_for_fullscreen
  self
end

#fullyObject



49
50
51
52
# File 'lib/applitools/selenium/target.rb', line 49

def fully
  options[:stitch_content] = true
  self
end

#ignore(*args) ⇒ Object

Add the wanted ignored regions.

Parameters:

  • *args (Array)

    The arguments to ignore.

  • args (Hash)

    a customizable set of options

Options Hash (*args):

  • :name (String)

    The name of the region to ignore.

  • :id (Integer)

    The id of the region to ignore.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/applitools/selenium/target.rb', line 28

def ignore(*args)
  if args.first
    ignored_regions << if args.first.is_a? Applitools::Selenium::Element
                         proc do
                           args.first
                         end
                       else
                         proc do |driver|
                           driver.find_element(*args)
                         end
                       end
  else
    reset_ignore
  end
  self
end

#region(*args) ⇒ Applitools::Selenium::Target

Add the desired region.

Parameters:

  • *args (Array)

    The arguments to add.

  • args (Hash)

    a customizable set of options

Options Hash (*args):

  • :timeout (Integer)

    The timeout.

  • :id (Integer)

    The id of the region.

Returns:



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/applitools/selenium/target.rb', line 71

def region(*args)
  self.region_to_check = if args.first.is_a? Applitools::Selenium::Element
                           proc do
                             args.first
                           end
                         else
                           proc do |driver|
                             driver.find_element(*args)
                           end
                         end
  self.coordinate_type = Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative]
  options[:timeout] = nil
  reset_ignore
  self
end

#timeout(value) ⇒ Object



54
55
56
57
# File 'lib/applitools/selenium/target.rb', line 54

def timeout(value)
  options[:timeout] = value
  self
end

#trimObject



87
88
89
90
# File 'lib/applitools/selenium/target.rb', line 87

def trim
  options[:trim] = true
  self
end