Class: Applitools::Selenium::RGridDom

Inherits:
Object
  • Object
show all
Includes:
Jsonable
Defined in:
lib/applitools/selenium/rgrid_dom.rb

Constant Summary collapse

CONTENT_TYPE =
'x-applitools-html/cdt'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RGridDom

Returns a new instance of RGridDom.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/applitools/selenium/rgrid_dom.rb', line 10

def initialize(*args)
  options = Applitools::Utils.extract_options! args
  self.url = options[:url]
  self.dom_nodes = options[:dom_nodes]
  self.resources = options[:resources]
  self.hash_format = 'sha256'
  self.data = {
    'resources' => resources,
    'domNodes' => dom_nodes
  }
  self.hash = calculate_sha_256
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



8
9
10
# File 'lib/applitools/selenium/rgrid_dom.rb', line 8

def data
  @data
end

#dom_nodesObject

Returns the value of attribute dom_nodes.



8
9
10
# File 'lib/applitools/selenium/rgrid_dom.rb', line 8

def dom_nodes
  @dom_nodes
end

#resourcesObject

Returns the value of attribute resources.



8
9
10
# File 'lib/applitools/selenium/rgrid_dom.rb', line 8

def resources
  @resources
end

#urlObject

Returns the value of attribute url.



8
9
10
# File 'lib/applitools/selenium/rgrid_dom.rb', line 8

def url
  @url
end

Instance Method Details

#calculate_sha_256Object



23
24
25
# File 'lib/applitools/selenium/rgrid_dom.rb', line 23

def calculate_sha_256
  Digest::SHA256.hexdigest(content)
end

#contentObject



27
28
29
# File 'lib/applitools/selenium/rgrid_dom.rb', line 27

def content
  Oj.dump(json_value(data.sort.to_h))
end

#resourceObject



31
32
33
34
35
36
37
# File 'lib/applitools/selenium/rgrid_dom.rb', line 31

def resource
  Applitools::Selenium::VGResource.new(
    url,
    CONTENT_TYPE,
    content
  )
end