percy-appium-app 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/percy/environment.rb +15 -13
- data/percy/exceptions/exceptions.rb +0 -2
- data/percy/lib/app_percy.rb +36 -34
- data/percy/lib/cache.rb +42 -41
- data/percy/lib/cli_wrapper.rb +94 -92
- data/percy/lib/ignore_region.rb +4 -3
- data/percy/lib/percy_automate.rb +44 -42
- data/percy/lib/percy_options.rb +30 -28
- data/percy/lib/region.rb +15 -13
- data/percy/lib/tile.rb +24 -22
- data/percy/metadata/android_metadata.rb +60 -58
- data/percy/metadata/driver_metadata.rb +29 -27
- data/percy/metadata/ios_metadata.rb +64 -62
- data/percy/metadata/metadata.rb +80 -78
- data/percy/metadata/metadata_resolver.rb +14 -12
- data/percy/{screenshot.rb → percy-appium-app.rb} +3 -3
- data/percy/providers/app_automate.rb +131 -129
- data/percy/providers/generic_provider.rb +166 -164
- data/percy/providers/provider_resolver.rb +9 -7
- data/percy/version.rb +1 -1
- data/percy-appium-app.gemspec +1 -0
- data/specs/android_metadata.rb +2 -4
- data/specs/app_automate.rb +10 -13
- data/specs/app_percy.rb +20 -22
- data/specs/cache.rb +16 -16
- data/specs/cli_wrapper.rb +6 -8
- data/specs/driver_metadata.rb +2 -4
- data/specs/generic_providers.rb +9 -12
- data/specs/ignore_regions.rb +10 -12
- data/specs/ios_metadata.rb +2 -2
- data/specs/metadata.rb +2 -5
- data/specs/metadata_resolver.rb +6 -6
- data/specs/mocks/mock_methods.rb +0 -2
- data/specs/percy_options.rb +16 -16
- data/specs/screenshot.rb +7 -10
- data/specs/tile.rb +2 -2
- metadata +17 -3
@@ -7,14 +7,14 @@ require_relative 'lib/cli_wrapper'
|
|
7
7
|
require_relative 'environment'
|
8
8
|
|
9
9
|
def percy_screenshot(driver, name, **kwargs)
|
10
|
-
return nil unless CLIWrapper.percy_enabled?
|
10
|
+
return nil unless Percy::CLIWrapper.percy_enabled?
|
11
11
|
|
12
12
|
app_percy = nil
|
13
|
-
provider_class = Environment.session_type == 'automate' ? PercyOnAutomate : AppPercy
|
13
|
+
provider_class = Percy::Environment.session_type == 'automate' ? Percy::PercyOnAutomate : Percy::AppPercy
|
14
14
|
app_percy = provider_class.new(driver)
|
15
15
|
app_percy.screenshot(name, **kwargs)
|
16
16
|
rescue StandardError => e
|
17
|
-
CLIWrapper.post_failed_event(e.to_s)
|
17
|
+
Percy::CLIWrapper.post_failed_event(e.to_s)
|
18
18
|
log("Could not take screenshot \"#{name}\"")
|
19
19
|
raise e if app_percy && !app_percy.percy_options.ignore_errors
|
20
20
|
|
@@ -6,154 +6,156 @@ require_relative '../lib/tile'
|
|
6
6
|
require_relative 'generic_provider'
|
7
7
|
require_relative '../environment'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
r_index
|
14
|
-
|
15
|
-
|
9
|
+
module Percy
|
10
|
+
class AppAutomate < Percy::GenericProvider
|
11
|
+
def self.supports(remote_url)
|
12
|
+
r_index = remote_url.rindex(ENV['AA_DOMAIN'].nil? ? 'browserstack' : ENV['AA_DOMAIN'])
|
13
|
+
if r_index
|
14
|
+
r_index > -1
|
15
|
+
else
|
16
|
+
false
|
17
|
+
end
|
16
18
|
end
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
def screenshot(name, **kwargs)
|
21
|
+
session_details = execute_percy_screenshot_begin(name)
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
if session_details
|
24
|
+
metadata.device_name = session_details['deviceName']
|
25
|
+
metadata.os_version = session_details['osVersion']
|
26
|
+
set_debug_url(session_details)
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
begin
|
30
|
+
response = super(name, **kwargs)
|
31
|
+
percy_screenshot_url = response.fetch('link', '')
|
32
|
+
execute_percy_screenshot_end(name, percy_screenshot_url, 'success')
|
33
|
+
rescue StandardError => e
|
34
|
+
execute_percy_screenshot_end(name, percy_screenshot_url, 'failure', e.message)
|
35
|
+
raise e
|
36
|
+
end
|
35
37
|
end
|
36
|
-
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
def _get_tiles(**kwargs)
|
45
|
-
fullpage_ss = kwargs[:fullpage] || false
|
46
|
-
if ENV['PERCY_DISABLE_REMOTE_UPLOADS'] == 'true'
|
47
|
-
puts("Full page screenshots are only supported when 'PERCY_DISABLE_REMOTE_UPLOADS' is not set") if fullpage_ss
|
48
|
-
return super(**kwargs) unless fullpage_ss
|
39
|
+
def set_debug_url(session_details)
|
40
|
+
build_hash = session_details['buildHash'].to_s
|
41
|
+
session_hash = session_details['sessionHash'].to_s
|
42
|
+
@debug_url = "https://app-automate.browserstack.com/dashboard/v2/builds/#{build_hash}/sessions/#{session_hash}"
|
49
43
|
end
|
50
|
-
screenshot_type = fullpage_ss ? 'fullpage' : 'singlepage'
|
51
|
-
screen_lengths = kwargs[:screen_lengths] || 4
|
52
|
-
scrollable_xpath = kwargs[:scollable_xpath]
|
53
|
-
scrollable_id = kwargs[:scrollable_id]
|
54
|
-
top_scrollview_offset = kwargs[:top_scrollview_offset]
|
55
|
-
bottom_scrollview_offset = kwargs[:top_scrollview_offset]
|
56
44
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
nav_bar_height = metadata.navigation_bar_height
|
45
|
+
def _get_tiles(**kwargs)
|
46
|
+
fullpage_ss = kwargs[:fullpage] || false
|
47
|
+
if ENV['PERCY_DISABLE_REMOTE_UPLOADS'] == 'true'
|
48
|
+
puts("Full page screenshots are only supported when 'PERCY_DISABLE_REMOTE_UPLOADS' is not set") if fullpage_ss
|
49
|
+
return super(**kwargs) unless fullpage_ss
|
50
|
+
end
|
51
|
+
screenshot_type = fullpage_ss ? 'fullpage' : 'singlepage'
|
52
|
+
screen_lengths = kwargs[:screen_lengths] || 4
|
53
|
+
scrollable_xpath = kwargs[:scollable_xpath]
|
54
|
+
scrollable_id = kwargs[:scrollable_id]
|
55
|
+
top_scrollview_offset = kwargs[:top_scrollview_offset]
|
56
|
+
bottom_scrollview_offset = kwargs[:top_scrollview_offset]
|
70
57
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
58
|
+
data = execute_percy_screenshot(
|
59
|
+
metadata.device_screen_size.fetch('height', 1),
|
60
|
+
screenshot_type,
|
61
|
+
screen_lengths,
|
62
|
+
scrollable_xpath,
|
63
|
+
scrollable_id,
|
64
|
+
metadata.scale_factor,
|
65
|
+
top_scrollview_offset,
|
66
|
+
bottom_scrollview_offset
|
78
67
|
)
|
79
|
-
|
68
|
+
tiles = []
|
69
|
+
status_bar_height = metadata.status_bar_height
|
70
|
+
nav_bar_height = metadata.navigation_bar_height
|
80
71
|
|
81
|
-
|
82
|
-
|
72
|
+
JSON.parse(data['result']).each do |tile_data|
|
73
|
+
tiles << Percy::Tile.new(
|
74
|
+
status_bar_height,
|
75
|
+
nav_bar_height,
|
76
|
+
tile_data['header_height'],
|
77
|
+
tile_data['footer_height'],
|
78
|
+
sha: tile_data['sha'].split('-')[0]
|
79
|
+
)
|
80
|
+
end
|
83
81
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
82
|
+
tiles
|
83
|
+
end
|
84
|
+
|
85
|
+
def execute_percy_screenshot_begin(name)
|
86
|
+
request_body = {
|
87
|
+
action: 'percyScreenshot',
|
88
|
+
arguments: {
|
89
|
+
state: 'begin',
|
90
|
+
percyBuildId: Percy::Environment.percy_build_id,
|
91
|
+
percyBuildUrl: Percy::Environment.percy_build_url,
|
92
|
+
name: name
|
93
|
+
}
|
92
94
|
}
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
95
|
+
command = "browserstack_executor: #{request_body.to_json}"
|
96
|
+
begin
|
97
|
+
response = metadata.execute_script(command)
|
98
|
+
JSON.parse(response)
|
99
|
+
rescue StandardError => e
|
100
|
+
log('Could not set session as Percy session')
|
101
|
+
log('Error occurred during begin call', on_debug: true)
|
102
|
+
log(e, on_debug: true)
|
103
|
+
nil
|
104
|
+
end
|
103
105
|
end
|
104
|
-
end
|
105
106
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
107
|
+
def execute_percy_screenshot_end(name, percy_screenshot_url, status, status_message = nil)
|
108
|
+
request_body = {
|
109
|
+
action: 'percyScreenshot',
|
110
|
+
arguments: {
|
111
|
+
state: 'end',
|
112
|
+
percyScreenshotUrl: percy_screenshot_url,
|
113
|
+
name: name,
|
114
|
+
status: status
|
115
|
+
}
|
114
116
|
}
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
117
|
+
request_body[:arguments][:statusMessage] = status_message if status_message
|
118
|
+
command = "browserstack_executor: #{request_body.to_json}"
|
119
|
+
begin
|
120
|
+
metadata.execute_script(command)
|
121
|
+
rescue StandardError => e
|
122
|
+
log('Error occurred during end call', on_debug: true)
|
123
|
+
log(e, on_debug: true)
|
124
|
+
end
|
123
125
|
end
|
124
|
-
end
|
125
126
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
127
|
+
def execute_percy_screenshot(device_height, screenshotType, screen_lengths, scrollable_xpath = nil,
|
128
|
+
scrollable_id = nil, scale_factor = 1, top_scrollview_offset = 0,
|
129
|
+
bottom_scrollview_offset = 0)
|
130
|
+
project_id = ENV['PERCY_ENABLE_DEV'] == 'true' ? 'percy-dev' : 'percy-prod'
|
131
|
+
request_body = {
|
132
|
+
action: 'percyScreenshot',
|
133
|
+
arguments: {
|
134
|
+
state: 'screenshot',
|
135
|
+
percyBuildId: Percy::Environment.percy_build_id,
|
136
|
+
screenshotType: screenshotType,
|
137
|
+
projectId: project_id,
|
138
|
+
scaleFactor: scale_factor,
|
139
|
+
options: {
|
140
|
+
numOfTiles: screen_lengths,
|
141
|
+
deviceHeight: device_height,
|
142
|
+
scrollableXpath: scrollable_xpath,
|
143
|
+
scrollableId: scrollable_id,
|
144
|
+
topScrollviewOffset: top_scrollview_offset,
|
145
|
+
bottomScrollviewOffset: bottom_scrollview_offset,
|
146
|
+
'FORCE_FULL_PAGE' => ENV['FORCE_FULL_PAGE'] == 'true'
|
147
|
+
}
|
146
148
|
}
|
147
149
|
}
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
150
|
+
command = "browserstack_executor: #{request_body.to_json}"
|
151
|
+
begin
|
152
|
+
response = metadata.execute_script(command)
|
153
|
+
JSON.parse(response)
|
154
|
+
rescue StandardError => e
|
155
|
+
log('Error occurred during screenshot call', on_debug: true)
|
156
|
+
log(e, on_debug: true)
|
157
|
+
raise e
|
158
|
+
end
|
157
159
|
end
|
158
160
|
end
|
159
|
-
end
|
161
|
+
end
|