bugsnag-maze-runner 6.27.0 → 7.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/download-logs +14 -16
- data/bin/maze-runner +53 -15
- data/bin/upload-app +6 -6
- data/lib/features/steps/breadcrumb_steps.rb +44 -14
- data/lib/features/steps/error_reporting_steps.rb +16 -0
- data/lib/features/steps/network_steps.rb +66 -6
- data/lib/features/steps/payload_steps.rb +23 -0
- data/lib/features/steps/request_assertion_steps.rb +87 -8
- data/lib/features/steps/runner_steps.rb +22 -0
- data/lib/features/steps/session_tracking_steps.rb +1 -1
- data/lib/features/steps/trace_steps.rb +254 -0
- data/lib/features/support/internal_hooks.rb +31 -84
- data/lib/maze/api/appium/file_manager.rb +29 -0
- data/lib/maze/aws_public_ip.rb +53 -0
- data/lib/maze/checks/assert_check.rb +9 -31
- data/lib/maze/client/appium/base_client.rb +131 -0
- data/lib/maze/client/appium/bb_client.rb +102 -0
- data/lib/maze/client/appium/bb_devices.rb +127 -0
- data/lib/maze/client/appium/bs_client.rb +91 -0
- data/lib/maze/client/appium/bs_devices.rb +141 -0
- data/lib/maze/client/appium/bs_legacy_client.rb +31 -0
- data/lib/maze/client/appium/local_client.rb +67 -0
- data/lib/maze/client/appium.rb +23 -0
- data/lib/maze/client/bb_api_client.rb +102 -0
- data/lib/maze/client/bb_client_utils.rb +181 -0
- data/lib/maze/client/bs_client_utils.rb +168 -0
- data/lib/maze/client/selenium/base_client.rb +15 -0
- data/lib/maze/client/selenium/bb_browsers.yml +188 -0
- data/lib/maze/client/selenium/bb_client.rb +38 -0
- data/lib/maze/client/selenium/bs_browsers.yml +257 -0
- data/lib/maze/client/selenium/bs_client.rb +89 -0
- data/lib/maze/client/selenium/local_client.rb +16 -0
- data/lib/maze/client/selenium.rb +16 -0
- data/lib/maze/configuration.rb +18 -10
- data/lib/maze/docker.rb +40 -1
- data/lib/maze/driver/appium.rb +5 -24
- data/lib/maze/driver/browser.rb +12 -26
- data/lib/maze/errors.rb +32 -0
- data/lib/maze/generator.rb +55 -0
- data/lib/maze/helper.rb +7 -3
- data/lib/maze/hooks/appium_hooks.rb +29 -190
- data/lib/maze/hooks/browser_hooks.rb +2 -55
- data/lib/maze/hooks/error_code_hook.rb +49 -0
- data/lib/maze/hooks/hooks.rb +2 -2
- data/lib/maze/http_request.rb +21 -0
- data/lib/maze/logger.rb +16 -3
- data/lib/maze/maze_output.rb +88 -0
- data/lib/maze/option/parser.rb +17 -22
- data/lib/maze/option/processor.rb +21 -34
- data/lib/maze/option/validator.rb +38 -67
- data/lib/maze/option.rb +16 -18
- data/lib/maze/plugins/cucumber_report_plugin.rb +1 -1
- data/lib/maze/plugins/error_code_plugin.rb +21 -0
- data/lib/maze/request_list.rb +10 -5
- data/lib/maze/request_repeater.rb +49 -0
- data/lib/maze/retry_handler.rb +4 -13
- data/lib/maze/schemas/OtelTraceSchema.json +390 -0
- data/lib/maze/schemas/trace_schema.rb +7 -0
- data/lib/maze/schemas/trace_validator.rb +98 -0
- data/lib/maze/server.rb +74 -30
- data/lib/maze/servlets/base_servlet.rb +10 -5
- data/lib/maze/servlets/command_servlet.rb +10 -7
- data/lib/maze/servlets/log_servlet.rb +2 -2
- data/lib/maze/servlets/reflective_servlet.rb +12 -11
- data/lib/maze/servlets/servlet.rb +47 -8
- data/lib/maze/servlets/temp.rb +0 -0
- data/lib/maze/servlets/trace_servlet.rb +13 -0
- data/lib/maze.rb +2 -2
- data/lib/utils/deep_merge.rb +17 -0
- data/lib/utils/selenium_money_patch.rb +17 -0
- metadata +97 -17
- data/lib/maze/bitbar_devices.rb +0 -84
- data/lib/maze/bitbar_utils.rb +0 -112
- data/lib/maze/browser_stack_devices.rb +0 -160
- data/lib/maze/browser_stack_utils.rb +0 -164
- data/lib/maze/browsers_bs.yml +0 -220
- data/lib/maze/browsers_cbt.yml +0 -100
- data/lib/maze/capabilities.rb +0 -126
- data/lib/maze/driver/resilient_appium.rb +0 -51
- data/lib/maze/sauce_labs_utils.rb +0 -96
- data/lib/maze/smart_bear_utils.rb +0 -71
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Maze
|
4
|
+
module Client
|
5
|
+
module Appium
|
6
|
+
class BaseClient
|
7
|
+
FIXTURE_CONFIG = 'fixture_config.json'
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@session_ids = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def start_session
|
14
|
+
prepare_session
|
15
|
+
|
16
|
+
start_driver(Maze.config)
|
17
|
+
|
18
|
+
# Set bundle/app id for later use
|
19
|
+
Maze.driver.app_id = case Maze::Helper.get_current_platform
|
20
|
+
when 'android'
|
21
|
+
Maze.driver.session_capabilities['appPackage']
|
22
|
+
when 'ios'
|
23
|
+
Maze.driver.session_capabilities['CFBundleIdentifier'] # Present on BS and locally
|
24
|
+
end
|
25
|
+
# Ensure the device is unlocked
|
26
|
+
Maze.driver.unlock
|
27
|
+
|
28
|
+
log_run_intro
|
29
|
+
end
|
30
|
+
|
31
|
+
def prepare_session
|
32
|
+
raise 'Method not implemented by this class'
|
33
|
+
end
|
34
|
+
|
35
|
+
def maze_address
|
36
|
+
raise 'Method not implemented by this class'
|
37
|
+
end
|
38
|
+
|
39
|
+
def start_driver(config)
|
40
|
+
retry_failure = config.device_list.nil? || config.device_list.empty?
|
41
|
+
driver = nil
|
42
|
+
until Maze.driver
|
43
|
+
begin
|
44
|
+
start_driver_closure = Proc.new do
|
45
|
+
begin
|
46
|
+
config.capabilities = device_capabilities
|
47
|
+
driver = Maze::Driver::Appium.new config.appium_server_url,
|
48
|
+
config.capabilities,
|
49
|
+
config.locator
|
50
|
+
|
51
|
+
result = driver.start_driver
|
52
|
+
if result
|
53
|
+
# Log details of this session
|
54
|
+
$logger.info "Created Appium session: #{driver.session_id}"
|
55
|
+
@session_ids << driver.session_id
|
56
|
+
udid = driver.session_capabilities['udid']
|
57
|
+
$logger.info "Running on device: #{udid}" unless udid.nil?
|
58
|
+
end
|
59
|
+
result
|
60
|
+
rescue => start_error
|
61
|
+
$logger.error "Session creation failed: #{start_error}"
|
62
|
+
raise start_error unless retry_failure
|
63
|
+
false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
if retry_failure
|
68
|
+
wait = Maze::Wait.new(interval: 10, timeout: 60)
|
69
|
+
success = wait.until(&start_driver_closure)
|
70
|
+
|
71
|
+
unless success
|
72
|
+
$logger.error 'Appium driver failed to start after 6 attempts in 60 seconds'
|
73
|
+
raise RuntimeError.new('Appium driver failed to start in 60 seconds')
|
74
|
+
end
|
75
|
+
else
|
76
|
+
start_driver_closure.call
|
77
|
+
end
|
78
|
+
|
79
|
+
# Infer OS version if necessary when running locally
|
80
|
+
if Maze.config.farm == :local && Maze.config.os_version.nil?
|
81
|
+
version = case Maze.config.os
|
82
|
+
when 'android'
|
83
|
+
driver.session_capabilities['platformVersion'].to_f
|
84
|
+
when 'ios'
|
85
|
+
driver.session_capabilities['sdkVersion'].to_f
|
86
|
+
end
|
87
|
+
$logger.info "Inferred OS version to be #{version}"
|
88
|
+
Maze.config.os_version = version
|
89
|
+
end
|
90
|
+
|
91
|
+
Maze.driver = driver
|
92
|
+
rescue ::Selenium::WebDriver::Error::UnknownError => original_exception
|
93
|
+
$logger.warn "Attempt to acquire #{config.device} device from farm #{config.farm} failed"
|
94
|
+
$logger.warn "Exception: #{original_exception.message}"
|
95
|
+
if config.device_list.empty?
|
96
|
+
$logger.error 'No further devices to try - raising original exception'
|
97
|
+
raise original_exception
|
98
|
+
else
|
99
|
+
config.device = config.device_list.first
|
100
|
+
config.device_list = config.device_list.drop(1)
|
101
|
+
$logger.warn "Retrying driver initialisation using next device: #{config.device}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def start_scenario
|
108
|
+
# Launch the app on macOS
|
109
|
+
Maze.driver.get(Maze.config.app) if Maze.config.os == 'macos'
|
110
|
+
end
|
111
|
+
|
112
|
+
def device_capabilities
|
113
|
+
raise 'Method not implemented by this class'
|
114
|
+
end
|
115
|
+
|
116
|
+
def log_run_intro
|
117
|
+
raise 'Method not implemented by this class'
|
118
|
+
end
|
119
|
+
|
120
|
+
def log_run_outro
|
121
|
+
raise 'Method not implemented by this class'
|
122
|
+
end
|
123
|
+
|
124
|
+
def stop_session
|
125
|
+
Maze.driver&.driver_quit
|
126
|
+
Maze::AppiumServer.stop if Maze::AppiumServer.running
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Maze
|
2
|
+
module Client
|
3
|
+
module Appium
|
4
|
+
class BitBarClient < BaseClient
|
5
|
+
def prepare_session
|
6
|
+
config = Maze.config
|
7
|
+
config.app = Maze::Client::BitBarClientUtils.upload_app config.access_key,
|
8
|
+
config.app
|
9
|
+
if Maze.config.start_tunnel
|
10
|
+
Maze::Client::BitBarClientUtils.start_local_tunnel config.sb_local,
|
11
|
+
config.username,
|
12
|
+
config.access_key
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def start_scenario
|
17
|
+
unless Maze.config.legacy_driver?
|
18
|
+
# Write Maze's address to file and push to the device
|
19
|
+
maze_address = Maze.public_address || "local:#{Maze.config.port}"
|
20
|
+
Maze::Api::Appium::FileManager.new.write_app_file(JSON.generate({ maze_address: maze_address }),
|
21
|
+
FIXTURE_CONFIG)
|
22
|
+
end
|
23
|
+
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def device_capabilities
|
28
|
+
config = Maze.config
|
29
|
+
capabilities = {
|
30
|
+
'noReset' => true,
|
31
|
+
'bitbar:options' => {
|
32
|
+
# Some capabilities probably belong in the top level
|
33
|
+
# of the hash, but BitBar picks them up from here.
|
34
|
+
'apiKey' => config.access_key,
|
35
|
+
'app' => config.app,
|
36
|
+
'findDevice' => false,
|
37
|
+
'testTimeout' => 7200,
|
38
|
+
'newCommandTimeout' => 0
|
39
|
+
}
|
40
|
+
}
|
41
|
+
capabilities['appiumVersion'] = config.appium_version unless config.appium_version.nil?
|
42
|
+
capabilities.deep_merge! dashboard_capabilities
|
43
|
+
capabilities.deep_merge! BitBarDevices.get_available_device(config.device)
|
44
|
+
capabilities.deep_merge! JSON.parse(config.capabilities_option)
|
45
|
+
capabilities
|
46
|
+
end
|
47
|
+
|
48
|
+
def log_run_intro
|
49
|
+
# Nothing to log at the start
|
50
|
+
end
|
51
|
+
|
52
|
+
def log_run_outro
|
53
|
+
api_client = BitBarApiClient.new(Maze.config.access_key)
|
54
|
+
|
55
|
+
$logger.info 'Appium session(s) created:'
|
56
|
+
@session_ids.each do |id|
|
57
|
+
link = api_client.get_device_session_ui_link(id)
|
58
|
+
$logger.info Maze::LogUtil.linkify(link, "BitBar session: #{id}") if link
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def stop_session
|
63
|
+
super
|
64
|
+
if Maze.config.start_tunnel
|
65
|
+
Maze::Client::BitBarClientUtils.stop_local_tunnel
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Determines capabilities used to organise sessions in the BitBar dashboard.
|
70
|
+
#
|
71
|
+
# @return [Hash] A hash containing the capabilities.
|
72
|
+
def dashboard_capabilities
|
73
|
+
# Attempt to use the current git repo as the project name
|
74
|
+
output, status = Maze::Runner.run_command('git rev-parse --show-toplevel')
|
75
|
+
if status == 0
|
76
|
+
project = File.basename(output[0].strip)
|
77
|
+
else
|
78
|
+
if ENV['BUILDKITE']
|
79
|
+
project = ENV['BUILDKITE_PIPELINE_SLUG']
|
80
|
+
else
|
81
|
+
$logger.warn 'Unable to determine project name, consider running Maze Runner from within a Git repository'
|
82
|
+
project = 'Unknown'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
if ENV['BUILDKITE']
|
87
|
+
test_run = "#{ENV['BUILDKITE_BUILD_NUMBER']} - #{ENV['BUILDKITE_LABEL']}"
|
88
|
+
else
|
89
|
+
test_run = Maze.run_uuid
|
90
|
+
end
|
91
|
+
|
92
|
+
{
|
93
|
+
'bitbar:options' => {
|
94
|
+
bitbar_project: project,
|
95
|
+
bitbar_testrun: test_run
|
96
|
+
}
|
97
|
+
}
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Maze
|
5
|
+
module Client
|
6
|
+
module Appium
|
7
|
+
# Provides a source of capabilities used to run tests against specific BitBar devices
|
8
|
+
# noinspection RubyStringKeysInHashInspection
|
9
|
+
class BitBarDevices
|
10
|
+
class << self
|
11
|
+
# Uses the BitBar API to find an available device from the group name given, or a device of that name
|
12
|
+
# @param device_or_group_name [String] Name of the device, or device group for which to find an available device
|
13
|
+
# @return Capabilities hash for the available device
|
14
|
+
def get_available_device(device_or_group_name)
|
15
|
+
api_client = BitBarApiClient.new(Maze.config.access_key)
|
16
|
+
device_group_id = api_client.get_device_group_id(device_or_group_name)
|
17
|
+
if device_group_id
|
18
|
+
# Device group found - find a free device in it
|
19
|
+
$logger.debug "Got group id #{device_group_id} for #{device_or_group_name}"
|
20
|
+
group_count, device = api_client.find_device_in_group(device_group_id)
|
21
|
+
if device.nil?
|
22
|
+
# TODO: Retry rather than fail, see PLAT-7377
|
23
|
+
Maze::Helper.error_exit 'There are no devices available'
|
24
|
+
else
|
25
|
+
$logger.info "#{group_count} device(s) currently available in group '#{device_or_group_name}'"
|
26
|
+
end
|
27
|
+
else
|
28
|
+
# See if there is a device with the given name
|
29
|
+
device = api_client.find_device device_or_group_name
|
30
|
+
end
|
31
|
+
|
32
|
+
device_name = device['displayName']
|
33
|
+
platform = device['platform'].downcase
|
34
|
+
platform_version = device['softwareVersion']['releaseVersion']
|
35
|
+
|
36
|
+
$logger.info "Selected device: #{device_name} (#{platform} #{platform_version})"
|
37
|
+
|
38
|
+
# TODO: Setting the config here is rather a side effect and factoring it out would be better.
|
39
|
+
# For now, though, it means not having to provide the --os and --os-version options on the command line.
|
40
|
+
Maze.config.os = platform
|
41
|
+
Maze.config.os_version = platform_version.to_f.floor
|
42
|
+
|
43
|
+
case platform
|
44
|
+
when 'android'
|
45
|
+
automation_name = if platform_version.start_with?('5')
|
46
|
+
'UiAutomator1'
|
47
|
+
else
|
48
|
+
'UiAutomator2'
|
49
|
+
end
|
50
|
+
make_android_hash(device_name, automation_name)
|
51
|
+
when 'ios'
|
52
|
+
make_ios_hash(device_name)
|
53
|
+
else
|
54
|
+
throw "Invalid device platform specified #{platform}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def list_device_groups(access_key)
|
59
|
+
api_client = BitBarApiClient.new(access_key)
|
60
|
+
device_groups = api_client.get_device_group_list
|
61
|
+
unless device_groups['data'] && !device_groups['data'].empty?
|
62
|
+
puts 'There are no device groups available for the given user access key'
|
63
|
+
exit 1
|
64
|
+
end
|
65
|
+
puts "BitBar device groups available:"
|
66
|
+
device_groups['data'].sort_by{|g| g['displayName']}.each do |group|
|
67
|
+
puts '------------------------------'
|
68
|
+
puts "Group name : #{group['displayName']}"
|
69
|
+
puts "OS : #{group['osType']}"
|
70
|
+
puts "Device count : #{group['deviceCount']}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def list_devices_for_group(device_group, access_key)
|
75
|
+
api_client = BitBarApiClient.new(access_key)
|
76
|
+
group_id = api_client.get_device_group_id(device_group)
|
77
|
+
unless group_id
|
78
|
+
puts "No device groups were found with the given name #{device_group}"
|
79
|
+
return
|
80
|
+
end
|
81
|
+
devices = api_client.get_device_list_for_group(group_id)
|
82
|
+
if devices['data'].empty?
|
83
|
+
puts "There are no devices available for the #{device_group} device group"
|
84
|
+
return
|
85
|
+
end
|
86
|
+
puts "BitBar devices available for device group #{device_group}:"
|
87
|
+
devices['data'].sort_by{|d| d['displayName']}.each do |device|
|
88
|
+
puts '------------------------------'
|
89
|
+
puts "Device name : #{device['displayName']}"
|
90
|
+
puts "OS : #{device['platform']} #{device['softwareVersion']['releaseVersion']}"
|
91
|
+
|
92
|
+
if device['platform'].eql? 'ANDROID'
|
93
|
+
puts "API level : #{device['softwareVersion']['apiLevel']}"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def make_android_hash(device, automation_name)
|
99
|
+
hash = {
|
100
|
+
'automationName' => automation_name,
|
101
|
+
'platformName' => 'Android',
|
102
|
+
'deviceName' => 'Android Phone',
|
103
|
+
'bitbar:options' => {
|
104
|
+
'autoGrantPermissions' => true,
|
105
|
+
'device' => device,
|
106
|
+
}
|
107
|
+
}
|
108
|
+
hash.freeze
|
109
|
+
end
|
110
|
+
|
111
|
+
def make_ios_hash(device)
|
112
|
+
{
|
113
|
+
'automationName' => 'XCUITest',
|
114
|
+
'deviceName' => 'iPhone device',
|
115
|
+
'platformName' => 'iOS',
|
116
|
+
'bitbar:options' => {
|
117
|
+
'noReset' => 'true',
|
118
|
+
'shouldTerminateApp' => 'true',
|
119
|
+
'device' => device
|
120
|
+
}
|
121
|
+
}.freeze
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Maze
|
2
|
+
module Client
|
3
|
+
module Appium
|
4
|
+
class BrowserStackClient < BaseClient
|
5
|
+
def prepare_session
|
6
|
+
# Upload the app and start the secure tunnel
|
7
|
+
config = Maze.config
|
8
|
+
config.app = Maze::Client::BrowserStackClientUtils.upload_app config.username,
|
9
|
+
config.access_key,
|
10
|
+
config.app
|
11
|
+
if Maze.config.start_tunnel
|
12
|
+
Maze::Client::BrowserStackClientUtils.start_local_tunnel config.bs_local,
|
13
|
+
Maze.run_uuid,
|
14
|
+
config.access_key
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def start_scenario
|
19
|
+
unless Maze.config.legacy_driver?
|
20
|
+
# Write Maze's address to file and push to the device
|
21
|
+
maze_address = "bs-local.com:#{Maze.config.port}"
|
22
|
+
Maze::Api::Appium::FileManager.new.write_app_file(JSON.generate({ maze_address: maze_address }),
|
23
|
+
FIXTURE_CONFIG)
|
24
|
+
end
|
25
|
+
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def device_capabilities
|
30
|
+
config = Maze.config
|
31
|
+
capabilities = {
|
32
|
+
'app' => config.app,
|
33
|
+
'deviceOrientation' => 'portrait',
|
34
|
+
'noReset' => 'true',
|
35
|
+
'bstack:options' => {}
|
36
|
+
}
|
37
|
+
device_caps = Maze::Client::Appium::BrowserStackDevices::DEVICE_HASH[config.device]
|
38
|
+
capabilities.deep_merge! device_caps
|
39
|
+
capabilities.deep_merge! JSON.parse(config.capabilities_option)
|
40
|
+
capabilities.merge! project_name_capabilities
|
41
|
+
capabilities['bstack:options']['appiumVersion'] = config.appium_version unless config.appium_version.nil?
|
42
|
+
unless device_caps['platformName'] == 'android' && device_caps['platformVersion'].to_i <= 6
|
43
|
+
capabilities['bstack:options']['disableAnimations'] = 'true'
|
44
|
+
end
|
45
|
+
if Maze.config.start_tunnel
|
46
|
+
capabilities['bstack:options']['local'] = 'true'
|
47
|
+
capabilities['bstack:options']['localIdentifier'] = Maze.run_uuid
|
48
|
+
end
|
49
|
+
|
50
|
+
capabilities
|
51
|
+
end
|
52
|
+
|
53
|
+
def log_run_intro
|
54
|
+
# Log a link to the BrowserStack session search dashboard
|
55
|
+
url = "https://app-automate.browserstack.com/dashboard/v2/search?query=#{Maze.run_uuid}&type=builds"
|
56
|
+
$logger.info Maze::LogUtil.linkify(url, 'BrowserStack session(s)')
|
57
|
+
end
|
58
|
+
|
59
|
+
def log_run_outro
|
60
|
+
$logger.info 'Appium session(s) created:'
|
61
|
+
@session_ids.each { |id| $logger.info " #{id}" }
|
62
|
+
log_run_intro
|
63
|
+
end
|
64
|
+
|
65
|
+
def stop_session
|
66
|
+
super
|
67
|
+
Maze::Client::BrowserStackClientUtils.stop_local_tunnel if Maze.config.start_tunnel
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
# Determines and returns sensible project, build, and name capabilities
|
73
|
+
#
|
74
|
+
# @return [Hash] A hash containing the 'project' and 'build' capabilities
|
75
|
+
def project_name_capabilities
|
76
|
+
# Default to values for running locally
|
77
|
+
project = 'local'
|
78
|
+
|
79
|
+
if ENV['BUILDKITE']
|
80
|
+
# Project
|
81
|
+
project = ENV['BUILDKITE_PIPELINE_NAME']
|
82
|
+
end
|
83
|
+
{
|
84
|
+
project: project,
|
85
|
+
build: Maze.run_uuid
|
86
|
+
}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Maze
|
4
|
+
module Client
|
5
|
+
module Appium
|
6
|
+
# Provides a source of capabilities used to run tests against specific BrowserStack devices
|
7
|
+
# noinspection RubyStringKeysInHashInspection
|
8
|
+
class BrowserStackDevices
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def list_devices(os)
|
12
|
+
puts "BrowserStack #{os} devices available:"
|
13
|
+
devices = DEVICE_HASH.dup
|
14
|
+
devices.select { |key, device|
|
15
|
+
device['platformName'].eql?(os)
|
16
|
+
}.map { |key, device|
|
17
|
+
new_device = device.dup
|
18
|
+
new_device['key'] = key
|
19
|
+
new_device
|
20
|
+
}.sort { |dev_1, dev_2|
|
21
|
+
dev_1['platformVersion'].to_f <=> dev_2['platformVersion'].to_f
|
22
|
+
}.each{ |device|
|
23
|
+
puts '------------------------------'
|
24
|
+
puts "Device key: #{device['key']}"
|
25
|
+
puts "Device: #{device['deviceName']}"
|
26
|
+
puts "OS: #{device['platformName']}"
|
27
|
+
puts "OS version: #{device['platformVersion']}"
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def make_android_hash(device, version)
|
32
|
+
hash = {
|
33
|
+
'platformName' => 'android',
|
34
|
+
'platformVersion' => version,
|
35
|
+
'deviceName' => device,
|
36
|
+
'autoGrantPermissions' => 'true',
|
37
|
+
}
|
38
|
+
hash.freeze
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_android(device, version, hash)
|
42
|
+
# Key format is "ANDROID_<version>_<device>", with:
|
43
|
+
# - dots in versions and all spaces replaced with underscores
|
44
|
+
# - device made upper case
|
45
|
+
name = device.upcase.gsub ' ', '_'
|
46
|
+
new_version = version.gsub '.', '_'
|
47
|
+
key = "ANDROID_#{new_version}_#{name}"
|
48
|
+
hash[key] = make_android_hash device, version
|
49
|
+
end
|
50
|
+
|
51
|
+
def make_ios_hash(device, version)
|
52
|
+
{
|
53
|
+
'platformName' => 'ios',
|
54
|
+
'platformVersion' => version,
|
55
|
+
'deviceName' => device
|
56
|
+
}.freeze
|
57
|
+
end
|
58
|
+
|
59
|
+
def add_ios(device, version, hash)
|
60
|
+
# Key format is "IOS_<version>_<device>", with:
|
61
|
+
# - dots in versions and all spaces replaced with underscores
|
62
|
+
# - device made upper case
|
63
|
+
name = device.upcase.gsub ' ', '_'
|
64
|
+
name = name.gsub '.', '_'
|
65
|
+
new_version = version.gsub '.', '_'
|
66
|
+
key = "IOS_#{new_version}_#{name}"
|
67
|
+
hash[key] = make_ios_hash device, version
|
68
|
+
end
|
69
|
+
|
70
|
+
def create_hash
|
71
|
+
hash = {
|
72
|
+
# Classic, non-specific devices for each Android version
|
73
|
+
'ANDROID_13_0' => make_android_hash('Google Pixel 6 Pro', '13.0'),
|
74
|
+
'ANDROID_13_0_BETA' => make_android_hash('Google Pixel 6 Pro', '13 Beta'),
|
75
|
+
'ANDROID_12_0' => make_android_hash('Google Pixel 5', '12.0'),
|
76
|
+
'ANDROID_11_0' => make_android_hash('Google Pixel 4', '11.0'),
|
77
|
+
'ANDROID_10_0' => make_android_hash('Google Pixel 4', '10.0'),
|
78
|
+
'ANDROID_9_0' => make_android_hash('Google Pixel 3', '9.0'),
|
79
|
+
'ANDROID_8_1' => make_android_hash('Samsung Galaxy Note 9', '8.1'),
|
80
|
+
'ANDROID_8_0' => make_android_hash('Google Pixel 2', '8.0'),
|
81
|
+
'ANDROID_7_1' => make_android_hash('Google Pixel', '7.1'),
|
82
|
+
|
83
|
+
# iOS devices
|
84
|
+
'IOS_16' => make_ios_hash('iPhone 14', '16'),
|
85
|
+
'IOS_15' => make_ios_hash('iPhone 11 Pro', '15'),
|
86
|
+
'IOS_14' => make_ios_hash('iPhone 11', '14'),
|
87
|
+
'IOS_13' => make_ios_hash('iPhone 8', '13'),
|
88
|
+
'IOS_12' => make_ios_hash('iPhone 8', '12'),
|
89
|
+
'IOS_11' => make_ios_hash('iPhone 8', '11'),
|
90
|
+
'IOS_10' => make_ios_hash('iPhone 7', '10')
|
91
|
+
}
|
92
|
+
|
93
|
+
# Specific Android devices
|
94
|
+
add_android 'Google Pixel 4', '11.0', hash # ANDROID_11_0_GOOGLE_PIXEL_4
|
95
|
+
|
96
|
+
add_android 'Xiaomi Redmi Note 9', '10.0', hash # ANDROID_10_0_XIAOMI_REDMI_NOTE_9
|
97
|
+
add_android 'Samsung Galaxy Note 20', '10.0', hash # ANDROID_10_0_SAMSUNG_GALAXY_NOTE_20
|
98
|
+
add_android 'Motorola Moto G9 Play', '10.0', hash # ANDROID_10_0_MOTOROLA_MOTO_G9_PLAY
|
99
|
+
add_android 'OnePlus 8', '10.0', hash # ANDROID_10_0_ONEPLUS_8
|
100
|
+
|
101
|
+
add_android 'Google Pixel 2', '9.0', hash # ANDROID_9_0_GOOGLE_PIXEL_2
|
102
|
+
add_android 'Samsung Galaxy Note 9', '8.1', hash # ANDROID_8_1_SAMSUNG_GALAXY_NOTE_9
|
103
|
+
add_android 'Samsung Galaxy J7 Prime', '8.1', hash # ANDROID_8_1_SAMSUNG_GALAXY_J7_PRIME
|
104
|
+
add_android 'Samsung Galaxy Tab S4', '8.1', hash # ANDROID_8_1_SAMSUNG_GALAXY_TAB_S4
|
105
|
+
add_android 'Samsung Galaxy Tab S3', '8.0', hash # ANDROID_8_0_SAMSUNG_GALAXY_TAB_S3
|
106
|
+
add_android 'Google Pixel 2', '8.0', hash # ANDROID_8_0_GOOGLE_PIXEL_2
|
107
|
+
add_android 'Samsung Galaxy S9', '8.0', hash # ANDROID_8_0_SAMSUNG_GALAXY_S9
|
108
|
+
add_android 'Samsung Galaxy S9 Plus', '8.0', hash # ANDROID_8_0_SAMSUNG_GALAXY_S9_PLUS
|
109
|
+
|
110
|
+
add_android 'Samsung Galaxy A8', '7.1', hash # ANDROID_7_1_SAMSUNG_GALAXY_A8
|
111
|
+
add_android 'Samsung Galaxy Note 8', '7.1', hash # ANDROID_7_1_SAMSUNG_GALAXY_NOTE_8
|
112
|
+
add_android 'Samsung Galaxy S8', '7.0', hash # ANDROID_7_0_SAMSUNG_GALAXY_S8
|
113
|
+
add_android 'Samsung Galaxy S8 Plus', '7.0', hash # ANDROID_7_0_SAMSUNG_GALAXY_S8_PLUS
|
114
|
+
|
115
|
+
# Specific iOS devices
|
116
|
+
add_ios 'iPhone 14 Plus', '16.0', hash # IOS_16_0_IPHONE_14_PLUS
|
117
|
+
add_ios 'iPhone 14 Pro', '16.0', hash # IOS_16_0_IPHONE_14_PRO
|
118
|
+
add_ios 'iPhone 14 Pro Max', '16.0', hash # IOS_16_0_IPHONE_14_PRO_MAX
|
119
|
+
|
120
|
+
add_ios 'iPhone 8 Plus', '11.0', hash # IOS_11_0_IPHONE_8_PLUS
|
121
|
+
add_ios 'iPhone X', '11.0', hash # IOS_11_0_IPHONE_X
|
122
|
+
add_ios 'iPhone SE', '11.0', hash # IOS_11_0_IPHONE_SE
|
123
|
+
add_ios 'iPhone 6', '11.0', hash # IOS_11_0_IPHONE_6
|
124
|
+
add_ios 'iPhone 6S', '11.0', hash # IOS_11_0_IPHONE_6S
|
125
|
+
add_ios 'iPhone 6S Plus', '11.0', hash # IOS_11_0_IPHONE_6S_PLUS
|
126
|
+
add_ios 'iPad 5th', '11.0', hash # IOS_11_0_IPAD_5TH
|
127
|
+
add_ios 'iPad Mini 4', '11.0', hash # IOS_11_0_IPAD_MINI_4
|
128
|
+
add_ios 'iPad Pro 9.7 2016', '11.0', hash # IOS_11_0_IPAD_PRO_9_7_2016
|
129
|
+
add_ios 'iPad 6th', '11.0', hash # IOS_11_0_IPAD_6TH
|
130
|
+
add_ios 'iPad Pro 12.9', '11.0', hash # IOS_11_0_IPAD_PRO_12_9
|
131
|
+
|
132
|
+
hash
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# The hash of device capabilities, accessible by simple names
|
137
|
+
DEVICE_HASH = create_hash
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Maze
|
2
|
+
module Client
|
3
|
+
module Appium
|
4
|
+
class BrowserStackLegacyClient < BrowserStackClient
|
5
|
+
def device_capabilities
|
6
|
+
config = Maze.config
|
7
|
+
capabilities = {
|
8
|
+
'app' => config.app,
|
9
|
+
'browserstack.console' => 'errors',
|
10
|
+
'deviceOrientation' => 'portrait',
|
11
|
+
'noReset' => 'true'
|
12
|
+
}
|
13
|
+
device_caps = Maze::Client::Appium::BrowserStackDevices::DEVICE_HASH[config.device]
|
14
|
+
capabilities.deep_merge! device_caps
|
15
|
+
capabilities.deep_merge! JSON.parse(config.capabilities_option)
|
16
|
+
capabilities.merge! project_name_capabilities
|
17
|
+
capabilities['browserstack.appium_version'] = config.appium_version unless config.appium_version.nil?
|
18
|
+
unless device_caps['platformName'] == 'android' && device_caps['platformVersion'].to_i <= 6
|
19
|
+
capabilities['disableAnimations'] = 'true'
|
20
|
+
end
|
21
|
+
if Maze.config.start_tunnel
|
22
|
+
capabilities['browserstack.localIdentifier'] = Maze.run_uuid
|
23
|
+
capabilities['browserstack.local'] = 'true'
|
24
|
+
end
|
25
|
+
|
26
|
+
capabilities
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|