percy-appium-app 0.0.1 → 0.0.2.pre.beta.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,124 +9,132 @@ require_relative '../exceptions/exceptions'
9
9
  require_relative '../version'
10
10
  require_relative '../environment'
11
11
 
12
- CLIENT_INFO = "percy-appium-app/#{SDK_VERSION}"
13
- ENV_INFO = ["appium/#{Appium::VERSION}", "ruby/#{RUBY_VERSION}"].freeze
12
+ module Percy
13
+ CLIENT_INFO = "percy-appium-app/#{VERSION}"
14
+ ENV_INFO = ["appium/#{Appium::VERSION}", "ruby/#{RUBY_VERSION}"].freeze
14
15
 
15
- PERCY_CLI_API = ENV['PERCY_CLI_API'] || 'http://localhost:5338'
16
+ PERCY_CLI_API = ENV['PERCY_CLI_API'] || 'http://localhost:5338'
16
17
 
17
- class CLIWrapper
18
- def initialize; end
18
+ class CLIWrapper
19
+ def initialize; end
19
20
 
20
- def self.percy_enabled?
21
- @percy_enabled ||= begin
22
- uri = URI("#{PERCY_CLI_API}/percy/healthcheck")
23
- response = Net::HTTP.get_response(uri)
21
+ def self.percy_enabled?
22
+ @percy_enabled ||= begin
23
+ uri = URI("#{PERCY_CLI_API}/percy/healthcheck")
24
+ response = Net::HTTP.get_response(uri)
24
25
 
25
- raise CLIException, response.body unless response.is_a?(Net::HTTPSuccess)
26
+ raise CLIException, response.body unless response.is_a?(Net::HTTPSuccess)
26
27
 
27
- data = JSON.parse(response.body)
28
- raise CLIException, data['error'] unless data['success']
28
+ data = JSON.parse(response.body)
29
+ raise CLIException, data['error'] unless data['success']
30
+
31
+ Percy::Environment.percy_build_id = data['build']['id']
32
+ Percy::Environment.percy_build_url = data['build']['url']
33
+ Percy::Environment.session_type = data.fetch('type', nil)
29
34
 
30
- Environment.percy_build_id = data['build']['id']
31
- Environment.percy_build_url = data['build']['url']
32
- Environment.session_type = data.fetch('type', nil)
35
+ version = response['x-percy-core-version']
36
+ if version.split('.')[0] != '1'
37
+ log("Unsupported Percy CLI version, #{version}")
38
+ return false
39
+ end
40
+ return true unless version.split('.')[1].to_i < 27
33
41
 
34
- version = response['x-percy-core-version']
35
- if version.split('.')[0] != '1'
36
- log("Unsupported Percy CLI version, #{version}")
42
+ log('Please upgrade to the latest CLI version for using this SDK. Minimum compatible version is 1.27.0-beta.0')
43
+ return false
44
+ rescue StandardError => e
45
+ log('Percy is not running, disabling screenshots')
46
+ log(e, on_debug: true)
37
47
  return false
38
48
  end
39
- return true unless version.split('.')[1].to_i < 27
40
-
41
- log('Please upgrade to the latest CLI version for using this SDK. Minimum compatible version is 1.27.0-beta.0')
42
- return false
43
- rescue StandardError => e
44
- log('Percy is not running, disabling screenshots')
45
- log(e, on_debug: true)
46
- return false
47
49
  end
48
- end
49
50
 
50
- def post_screenshots(name, tag, tiles, external_debug_url = nil, ignored_elements_data = nil,
51
- considered_elements_data = nil)
52
- body = request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data)
53
- body['client_info'] = Environment.get_client_info
54
- body['environment_info'] = Environment.get_env_info
51
+ def post_screenshots(name, tag, tiles, external_debug_url = nil, ignored_elements_data = nil,
52
+ considered_elements_data = nil, sync = nil)
53
+ body = request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data, sync)
54
+ body['client_info'] = Percy::Environment.get_client_info
55
+ body['environment_info'] = Percy::Environment.get_env_info
55
56
 
56
- uri = URI("#{PERCY_CLI_API}/percy/comparison")
57
- http = Net::HTTP.new(uri.host, uri.port)
58
- request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
59
- request.body = body.to_json
57
+ uri = URI("#{PERCY_CLI_API}/percy/comparison")
58
+ http = Net::HTTP.new(uri.host, uri.port)
59
+ http.read_timeout = 600 # seconds
60
+ request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
61
+ request.body = body.to_json
60
62
 
61
- response = http.request(request)
62
- data = JSON.parse(response.body)
63
-
64
- raise CLIException, data.fetch('error', 'UnknownException') if response.code != '200'
65
-
66
- data
67
- end
68
-
69
- def self.post_failed_event(error)
70
- body = {
71
- 'clientInfo' => Environment.get_client_info(true),
72
- 'message' => error,
73
- 'errorKind' => 'sdk'
74
- }
63
+ response = http.request(request)
64
+ data = JSON.parse(response.body)
75
65
 
76
- uri = URI("#{PERCY_CLI_API}/percy/events")
77
- response = Net::HTTP.post(uri, body.to_json, 'Content-Type' => 'application/json')
66
+ raise CLIException, data.fetch('error', 'UnknownException') if response.code != '200'
78
67
 
79
- # Handle errors
80
- if response.code.to_i != 200
81
- data = JSON.parse(response.body)
82
- error_message = data.fetch('error', 'UnknownException')
83
- raise CLIException, error_message
68
+ data
84
69
  end
85
70
 
86
- JSON.parse(response.body)
87
- rescue StandardError => e
88
- log(e.message, on_debug: true)
89
- nil
90
- end
91
-
92
- def post_poa_screenshots(name, session_id, command_executor_url, capabilities, desired_capabilities, options = nil)
93
- body = {
94
- 'sessionId' => session_id,
95
- 'commandExecutorUrl' => command_executor_url,
96
- 'capabilities' => capabilities.dup, # In Ruby, you can duplicate the hash with `dup`
97
- 'sessionCapabilities' => desired_capabilities.dup,
98
- 'snapshotName' => name,
99
- 'options' => options
100
- }
71
+ def self.post_failed_event(error)
72
+ body = {
73
+ 'clientInfo' => Percy::Environment.get_client_info(true),
74
+ 'message' => error,
75
+ 'errorKind' => 'sdk'
76
+ }
77
+
78
+ uri = URI("#{PERCY_CLI_API}/percy/events")
79
+ response = Net::HTTP.post(uri, body.to_json, 'Content-Type' => 'application/json')
80
+
81
+ # Handle errors
82
+ if response.code.to_i != 200
83
+ data = JSON.parse(response.body)
84
+ error_message = data.fetch('error', 'UnknownException')
85
+ raise CLIException, error_message
86
+ end
101
87
 
102
- body['client_info'] = Environment.get_client_info # Using class method without the underscore
103
- body['environment_info'] = Environment.get_env_info
88
+ JSON.parse(response.body)
89
+ rescue StandardError => e
90
+ log(e.message, on_debug: true)
91
+ nil
92
+ end
104
93
 
105
- uri = URI("#{PERCY_CLI_API}/percy/automateScreenshot")
106
- response = Net::HTTP.post(uri, body.to_json, 'Content-Type' => 'application/json')
94
+ def post_poa_screenshots(name, session_id, command_executor_url, capabilities, desired_capabilities, options = nil)
95
+ body = {
96
+ 'sessionId' => session_id,
97
+ 'commandExecutorUrl' => command_executor_url,
98
+ 'capabilities' => capabilities.dup, # In Ruby, you can duplicate the hash with `dup`
99
+ 'sessionCapabilities' => desired_capabilities.dup,
100
+ 'snapshotName' => name,
101
+ 'options' => options
102
+ }
103
+
104
+ body['client_info'] = Percy::Environment.get_client_info # Using class method without the underscore
105
+ body['environment_info'] = Percy::Environment.get_env_info
106
+
107
+ uri = URI("#{PERCY_CLI_API}/percy/automateScreenshot")
108
+ http = Net::HTTP.new(uri.host, uri.port)
109
+ http.read_timeout = 600 # seconds
110
+ request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
111
+ request.body = body.to_json
112
+ response = http.request(request)
113
+
114
+ # Handle errors
115
+ raise CLIException, "Error: #{response.message}" unless response.is_a?(Net::HTTPSuccess)
107
116
 
108
- # Handle errors
109
- raise CLIException, "Error: #{response.message}" unless response.is_a?(Net::HTTPSuccess)
117
+ data = JSON.parse(response.body)
110
118
 
111
- data = JSON.parse(response.body)
119
+ if response.code != '200'
120
+ error_message = data.fetch('error', 'UnknownException')
121
+ raise CLIException, error_message
122
+ end
112
123
 
113
- if response.code != '200'
114
- error_message = data.fetch('error', 'UnknownException')
115
- raise CLIException, error_message
124
+ data
116
125
  end
117
126
 
118
- data
119
- end
120
-
121
- def request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data)
122
- tiles = tiles.map(&:to_h)
123
- {
124
- 'name' => name,
125
- 'tag' => tag,
126
- 'tiles' => tiles,
127
- 'ignored_elements_data' => ignored_elements_data,
128
- 'external_debug_url' => external_debug_url,
129
- 'considered_elements_data' => considered_elements_data
130
- }
127
+ def request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data, sync)
128
+ tiles = tiles.map(&:to_h)
129
+ {
130
+ 'name' => name,
131
+ 'tag' => tag,
132
+ 'tiles' => tiles,
133
+ 'ignored_elements_data' => ignored_elements_data,
134
+ 'external_debug_url' => external_debug_url,
135
+ 'considered_elements_data' => considered_elements_data,
136
+ 'sync' => sync
137
+ }
138
+ end
131
139
  end
132
140
  end
@@ -2,7 +2,8 @@
2
2
 
3
3
  # lib/ignore_region.rb
4
4
  require_relative 'region'
5
-
6
- class IgnoreRegion < Region
7
- # Inherits everything from Region; no additional code needed unless you want to extend or modify the behavior
5
+ module Percy
6
+ class IgnoreRegion < Percy::Region
7
+ # Inherits everything from Percy::Region; no additional code needed unless you want to extend or modify the behavior
8
+ end
8
9
  end
@@ -10,50 +10,53 @@ IGNORE_ELEMENT_ALT_KEY = 'ignoreRegionAppiumElements'
10
10
  CONSIDER_ELEMENT_KEY = 'consider_region_appium_elements'
11
11
  CONSIDER_ELEMENT_ALT_KEY = 'considerRegionAppiumElements'
12
12
 
13
- class PercyOnAutomate
14
- def initialize(driver)
15
- unless driver.is_a?(Appium::Core::Base::Driver)
16
- raise DriverNotSupported, 'The provided driver instance is not supported.'
13
+ module Percy
14
+ class PercyOnAutomate
15
+ def initialize(driver)
16
+ unless driver.is_a?(Appium::Core::Base::Driver)
17
+ raise DriverNotSupported, 'The provided driver instance is not supported.'
18
+ end
19
+
20
+ @driver = driver
21
+ @percy_options = Percy::PercyOptions.new(@driver.capabilities)
17
22
  end
18
23
 
19
- @driver = driver
20
- @percy_options = PercyOptions.new(@driver.capabilities)
21
- end
22
-
23
- def screenshot(name, **options)
24
- return nil unless @percy_options.enabled
25
- raise TypeError, 'Argument name should be a string' unless name.is_a?(String)
26
- raise KeyError, 'Please pass the last parameter as "options" key' unless options.key?(:options)
27
-
28
- metadata = DriverMetadata.new(@driver)
29
- options = options[:options] || {}
30
-
31
- begin
32
- options[IGNORE_ELEMENT_KEY] = options.delete(IGNORE_ELEMENT_ALT_KEY) if options.key?(IGNORE_ELEMENT_ALT_KEY)
33
- options[CONSIDER_ELEMENT_KEY] = options.delete(CONSIDER_ELEMENT_ALT_KEY) if options.key?(CONSIDER_ELEMENT_ALT_KEY)
34
-
35
- ignore_region_elements = options.fetch(IGNORE_ELEMENT_KEY, []).map(&:id)
36
- consider_region_elements = options.fetch(CONSIDER_ELEMENT_KEY, []).map(&:id)
37
- options.delete(IGNORE_ELEMENT_KEY)
38
- options.delete(CONSIDER_ELEMENT_KEY)
39
-
40
- additional_options = {
41
- 'ignore_region_elements' => ignore_region_elements,
42
- 'consider_region_elements' => consider_region_elements
43
- }
44
-
45
- CLIWrapper.new.post_poa_screenshots(
46
- name,
47
- metadata.session_id,
48
- metadata.command_executor_url,
49
- metadata.capabilities,
50
- metadata.session_capabilities,
51
- options.merge(additional_options)
52
- )
53
- rescue StandardError => e
54
- log("Could not take Screenshot '#{name}'")
55
- log(e.message, on_debug: true)
24
+ def screenshot(name, **options)
25
+ return nil unless @percy_options.enabled
26
+ raise TypeError, 'Argument name should be a string' unless name.is_a?(String)
27
+ raise KeyError, 'Please pass the last parameter as "options" key' unless options.key?(:options)
28
+
29
+ metadata = Percy::DriverMetadata.new(@driver)
30
+ options = options[:options] || {}
31
+
32
+ begin
33
+ options[IGNORE_ELEMENT_KEY] = options.delete(IGNORE_ELEMENT_ALT_KEY) if options.key?(IGNORE_ELEMENT_ALT_KEY)
34
+ options[CONSIDER_ELEMENT_KEY] = options.delete(CONSIDER_ELEMENT_ALT_KEY) if options.key?(CONSIDER_ELEMENT_ALT_KEY)
35
+
36
+ ignore_region_elements = options.fetch(IGNORE_ELEMENT_KEY, []).map(&:id)
37
+ consider_region_elements = options.fetch(CONSIDER_ELEMENT_KEY, []).map(&:id)
38
+ options.delete(IGNORE_ELEMENT_KEY)
39
+ options.delete(CONSIDER_ELEMENT_KEY)
40
+
41
+ additional_options = {
42
+ 'ignore_region_elements' => ignore_region_elements,
43
+ 'consider_region_elements' => consider_region_elements
44
+ }
45
+
46
+ response = Percy::CLIWrapper.new.post_poa_screenshots(
47
+ name,
48
+ metadata.session_id,
49
+ metadata.command_executor_url,
50
+ metadata.capabilities,
51
+ metadata.session_capabilities,
52
+ options.merge(additional_options)
53
+ )
54
+
55
+ response['data']
56
+ rescue StandardError => e
57
+ log("Could not take Screenshot '#{name}'")
58
+ log(e.message, on_debug: true)
59
+ end
56
60
  end
57
- nil
58
61
  end
59
62
  end
@@ -1,37 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class PercyOptions
4
- IGNORE_ERRORS = 'ignoreErrors'
5
- ENABLED = 'enabled'
6
- PERCY_OPTIONS = ['percy:options', 'percyOptions'].freeze
3
+ module Percy
4
+ class PercyOptions
5
+ IGNORE_ERRORS = 'ignoreErrors'
6
+ ENABLED = 'enabled'
7
+ PERCY_OPTIONS = ['percy:options', 'percyOptions'].freeze
7
8
 
8
- def initialize(capabilities)
9
- @capabilities = capabilities
10
- @capabilities = @capabilities.as_json unless @capabilities.is_a?(Hash)
11
- @percy_options = _parse_percy_options || {}
12
- end
9
+ def initialize(capabilities)
10
+ @capabilities = capabilities
11
+ @capabilities = @capabilities.as_json unless @capabilities.is_a?(Hash)
12
+ @percy_options = _parse_percy_options || {}
13
+ end
13
14
 
14
- def _parse_percy_options
15
- options = PERCY_OPTIONS.map { |key| @capabilities.fetch(key, nil) }
16
- options = if options.any? { |element| !element.nil? }
17
- options[0] || options[1]
18
- else
19
- {}
20
- end
15
+ def _parse_percy_options
16
+ options = PERCY_OPTIONS.map { |key| @capabilities.fetch(key, nil) }
17
+ options = if options.any? { |element| !element.nil? }
18
+ options[0] || options[1]
19
+ else
20
+ {}
21
+ end
21
22
 
22
- if options
23
- options[IGNORE_ERRORS] = @capabilities.fetch("percy.#{IGNORE_ERRORS}", true) unless options.key?(IGNORE_ERRORS)
24
- options[ENABLED] = @capabilities.fetch("percy.#{ENABLED}", true) unless options.key?(ENABLED)
25
- end
23
+ if options
24
+ options[IGNORE_ERRORS] = @capabilities.fetch("percy.#{IGNORE_ERRORS}", true) unless options.key?(IGNORE_ERRORS)
25
+ options[ENABLED] = @capabilities.fetch("percy.#{ENABLED}", true) unless options.key?(ENABLED)
26
+ end
26
27
 
27
- options
28
- end
28
+ options
29
+ end
29
30
 
30
- def ignore_errors
31
- @percy_options.fetch(IGNORE_ERRORS, true)
32
- end
31
+ def ignore_errors
32
+ @percy_options.fetch(IGNORE_ERRORS, true)
33
+ end
33
34
 
34
- def enabled
35
- @percy_options.fetch(ENABLED, true)
35
+ def enabled
36
+ @percy_options.fetch(ENABLED, true)
37
+ end
36
38
  end
37
- end
39
+ end
data/percy/lib/region.rb CHANGED
@@ -1,22 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # lib/region.rb
4
- class Region
5
- attr_accessor :top, :bottom, :left, :right
4
+ module Percy
5
+ class Region
6
+ attr_accessor :top, :bottom, :left, :right
6
7
 
7
- def initialize(top, bottom, left, right)
8
- raise ArgumentError, 'Only Positive integer is allowed!' if [top, bottom, left, right].any?(&:negative?)
9
- raise ArgumentError, 'Invalid ignore region parameters!' if top >= bottom || left >= right
8
+ def initialize(top, bottom, left, right)
9
+ raise ArgumentError, 'Only Positive integer is allowed!' if [top, bottom, left, right].any?(&:negative?)
10
+ raise ArgumentError, 'Invalid ignore region parameters!' if top >= bottom || left >= right
10
11
 
11
- @top = top
12
- @bottom = bottom
13
- @left = left
14
- @right = right
15
- end
12
+ @top = top
13
+ @bottom = bottom
14
+ @left = left
15
+ @right = right
16
+ end
16
17
 
17
- def valid?(screen_height, screen_width)
18
- return false if @top >= screen_height || @bottom > screen_height || @left >= screen_width || @right > screen_width
18
+ def valid?(screen_height, screen_width)
19
+ return false if @top >= screen_height || @bottom > screen_height || @left >= screen_width || @right > screen_width
19
20
 
20
- true
21
+ true
22
+ end
21
23
  end
22
24
  end
data/percy/lib/tile.rb CHANGED
@@ -1,28 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Tile
4
- attr_reader :filepath, :status_bar_height, :nav_bar_height, :header_height, :footer_height, :fullscreen, :sha
3
+ module Percy
4
+ class Tile
5
+ attr_reader :filepath, :status_bar_height, :nav_bar_height, :header_height, :footer_height, :fullscreen, :sha
5
6
 
6
- def initialize(status_bar_height, nav_bar_height, header_height, footer_height, filepath: nil, sha: nil,
7
- fullscreen: false)
8
- @filepath = filepath
9
- @status_bar_height = status_bar_height
10
- @nav_bar_height = nav_bar_height
11
- @header_height = header_height
12
- @footer_height = footer_height
13
- @fullscreen = fullscreen
14
- @sha = sha
15
- end
7
+ def initialize(status_bar_height, nav_bar_height, header_height, footer_height, filepath: nil, sha: nil,
8
+ fullscreen: false)
9
+ @filepath = filepath
10
+ @status_bar_height = status_bar_height
11
+ @nav_bar_height = nav_bar_height
12
+ @header_height = header_height
13
+ @footer_height = footer_height
14
+ @fullscreen = fullscreen
15
+ @sha = sha
16
+ end
16
17
 
17
- def to_h
18
- {
19
- 'filepath' => @filepath,
20
- 'status_bar_height' => @status_bar_height,
21
- 'nav_bar_height' => @nav_bar_height,
22
- 'header_height' => @header_height,
23
- 'footer_height' => @footer_height,
24
- 'fullscreen' => @fullscreen,
25
- 'sha' => @sha
26
- }
18
+ def to_h
19
+ {
20
+ 'filepath' => @filepath,
21
+ 'status_bar_height' => @status_bar_height,
22
+ 'nav_bar_height' => @nav_bar_height,
23
+ 'header_height' => @header_height,
24
+ 'footer_height' => @footer_height,
25
+ 'fullscreen' => @fullscreen,
26
+ 'sha' => @sha
27
+ }
28
+ end
27
29
  end
28
30
  end
@@ -4,76 +4,78 @@ require 'json'
4
4
  require_relative 'metadata'
5
5
  require_relative '../lib/cache'
6
6
 
7
- class AndroidMetadata < Metadata
8
- def initialize(driver)
9
- super(driver)
10
- @_bars = nil
11
- @_viewport_rect = capabilities.to_json['viewportRect']
12
- end
7
+ module Percy
8
+ class AndroidMetadata < Percy::Metadata
9
+ def initialize(driver)
10
+ super(driver)
11
+ @_bars = nil
12
+ @_viewport_rect = capabilities.to_json['viewportRect']
13
+ end
13
14
 
14
- def device_screen_size
15
- caps = capabilities
16
- caps = caps.as_json unless caps.is_a?(Hash)
17
- width, height = caps['deviceScreenSize'].split('x')
18
- { 'width' => width.to_i, 'height' => height.to_i }
19
- end
15
+ def device_screen_size
16
+ caps = capabilities
17
+ caps = caps.as_json unless caps.is_a?(Hash)
18
+ width, height = caps['deviceScreenSize'].split('x')
19
+ { 'width' => width.to_i, 'height' => height.to_i }
20
+ end
20
21
 
21
- def get_system_bars
22
- @_bars = Cache.get_cache(session_id, Cache::SYSTEM_BARS)
23
- if @_viewport_rect
24
- begin
25
- @_bars = {
26
- 'statusBar' => { 'height' => @_viewport_rect['top'] },
27
- 'navigationBar' => {
28
- 'height' => device_screen_size['height'] - @_viewport_rect['height'] - @_viewport_rect['top']
22
+ def get_system_bars
23
+ @_bars = Percy::Cache.get_cache(session_id, Percy::Cache::SYSTEM_BARS)
24
+ if @_viewport_rect
25
+ begin
26
+ @_bars = {
27
+ 'statusBar' => { 'height' => @_viewport_rect['top'] },
28
+ 'navigationBar' => {
29
+ 'height' => device_screen_size['height'] - @_viewport_rect['height'] - @_viewport_rect['top']
30
+ }
29
31
  }
30
- }
31
- rescue StandardError
32
- @_bars = nil
32
+ rescue StandardError
33
+ @_bars = nil
34
+ end
33
35
  end
36
+ if @_bars.nil?
37
+ @_bars = driver.get_system_bars
38
+ Percy::Cache.set_cache(session_id, Percy::Cache::SYSTEM_BARS, @_bars)
39
+ end
40
+ @_bars
34
41
  end
35
- if @_bars.nil?
36
- @_bars = driver.get_system_bars
37
- Cache.set_cache(session_id, Cache::SYSTEM_BARS, @_bars)
38
- end
39
- @_bars
40
- end
41
42
 
42
- def status_bar
43
- status_bar = get_system_bars['statusBar']
44
- if status_bar['height'] == 1
45
- response = value_from_devices_info('status_bar', _device_name.upcase, os_version)
46
- return { 'height' => response }
43
+ def status_bar
44
+ status_bar = get_system_bars['statusBar']
45
+ if status_bar['height'] == 1
46
+ response = value_from_devices_info('status_bar', _device_name.upcase, os_version)
47
+ return { 'height' => response }
48
+ end
49
+ status_bar
47
50
  end
48
- status_bar
49
- end
50
51
 
51
- def navigation_bar
52
- navigation_bar = get_system_bars['navigationBar']
53
- if navigation_bar['height'] == 1
54
- response = { 'height' => value_from_devices_info('nav_bar', _device_name.upcase, os_version) }
55
- return response
52
+ def navigation_bar
53
+ navigation_bar = get_system_bars['navigationBar']
54
+ if navigation_bar['height'] == 1
55
+ response = { 'height' => value_from_devices_info('nav_bar', _device_name.upcase, os_version) }
56
+ return response
57
+ end
58
+ navigation_bar
56
59
  end
57
- navigation_bar
58
- end
59
60
 
60
- def viewport
61
- capabilities.to_json['viewportRect']
62
- end
61
+ def viewport
62
+ capabilities.to_json['viewportRect']
63
+ end
63
64
 
64
- def scale_factor
65
- 1
66
- end
65
+ def scale_factor
66
+ 1
67
+ end
67
68
 
68
- def _device_name
69
- if @device_name.nil?
70
- desired_caps = capabilities.to_json['desired'] || {}
71
- device_name = desired_caps['deviceName']
72
- device = desired_caps['device']
73
- device_name ||= device
74
- device_model = capabilities.to_json['deviceModel']
75
- @device_name = device_name || device_model
69
+ def _device_name
70
+ if @device_name.nil?
71
+ desired_caps = capabilities.to_json['desired'] || {}
72
+ device_name = desired_caps['deviceName']
73
+ device = desired_caps['device']
74
+ device_name ||= device
75
+ device_model = capabilities.to_json['deviceModel']
76
+ @device_name = device_name || device_model
77
+ end
78
+ @device_name
76
79
  end
77
- @device_name
78
80
  end
79
81
  end