Class: Maze::Client::Appium::BaseClient
- Inherits:
-
Object
- Object
- Maze::Client::Appium::BaseClient
show all
- Defined in:
- lib/maze/client/appium/base_client.rb
Constant Summary
collapse
- FIXTURE_CONFIG =
'fixture_config.json'
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BaseClient.
9
10
11
|
# File 'lib/maze/client/appium/base_client.rb', line 9
def initialize
@session_ids = []
end
|
Instance Method Details
#device_capabilities ⇒ Object
112
113
114
|
# File 'lib/maze/client/appium/base_client.rb', line 112
def device_capabilities
raise 'Method not implemented by this class'
end
|
#log_run_intro ⇒ Object
116
117
118
|
# File 'lib/maze/client/appium/base_client.rb', line 116
def log_run_intro
raise 'Method not implemented by this class'
end
|
#log_run_outro ⇒ Object
120
121
122
|
# File 'lib/maze/client/appium/base_client.rb', line 120
def log_run_outro
raise 'Method not implemented by this class'
end
|
#maze_address ⇒ Object
35
36
37
|
# File 'lib/maze/client/appium/base_client.rb', line 35
def maze_address
raise 'Method not implemented by this class'
end
|
#prepare_session ⇒ Object
31
32
33
|
# File 'lib/maze/client/appium/base_client.rb', line 31
def prepare_session
raise 'Method not implemented by this class'
end
|
#start_driver(config) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/maze/client/appium/base_client.rb', line 39
def start_driver(config)
retry_failure = config.device_list.nil? || config.device_list.empty?
driver = nil
until Maze.driver
begin
start_driver_closure = Proc.new do
begin
config.capabilities = device_capabilities
driver = Maze::Driver::Appium.new config.appium_server_url,
config.capabilities,
config.locator
result = driver.start_driver
if result
$logger.info "Created Appium session: #{driver.session_id}"
@session_ids << driver.session_id
udid = driver.session_capabilities['udid']
$logger.info "Running on device: #{udid}" unless udid.nil?
end
result
rescue => start_error
$logger.error "Session creation failed: #{start_error}"
raise start_error unless retry_failure
false
end
end
if retry_failure
wait = Maze::Wait.new(interval: 10, timeout: 60)
success = wait.until(&start_driver_closure)
unless success
$logger.error 'Appium driver failed to start after 6 attempts in 60 seconds'
raise RuntimeError.new('Appium driver failed to start in 60 seconds')
end
else
start_driver_closure.call
end
if Maze.config.farm == :local && Maze.config.os_version.nil?
version = case Maze.config.os
when 'android'
driver.session_capabilities['platformVersion'].to_f
when 'ios'
driver.session_capabilities['sdkVersion'].to_f
end
$logger.info "Inferred OS version to be #{version}"
Maze.config.os_version = version
end
Maze.driver = driver
rescue ::Selenium::WebDriver::Error::UnknownError => original_exception
$logger.warn "Attempt to acquire #{config.device} device from farm #{config.farm} failed"
$logger.warn "Exception: #{original_exception.message}"
if config.device_list.empty?
$logger.error 'No further devices to try - raising original exception'
raise original_exception
else
config.device = config.device_list.first
config.device_list = config.device_list.drop(1)
$logger.warn "Retrying driver initialisation using next device: #{config.device}"
end
end
end
end
|
#start_scenario ⇒ Object
107
108
109
110
|
# File 'lib/maze/client/appium/base_client.rb', line 107
def start_scenario
Maze.driver.get(Maze.config.app) if Maze.config.os == 'macos'
end
|