testcentricity_web 2.1.8.2 → 2.1.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +27 -0
- data/.rubocop.yml +41 -0
- data/.yardopts +2 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +28 -0
- data/README.md +1438 -0
- data/Rakefile +1 -0
- data/lib/devices/devices.yml +280 -0
- data/lib/testcentricity_web.rb +140 -0
- data/lib/testcentricity_web/browser_helper.rb +173 -0
- data/lib/testcentricity_web/data_objects_helper.rb +78 -0
- data/lib/testcentricity_web/drag_drop_helper.rb +15 -0
- data/lib/testcentricity_web/elements/button.rb +8 -0
- data/lib/testcentricity_web/elements/cell_button.rb +8 -0
- data/lib/testcentricity_web/elements/cell_checkbox.rb +38 -0
- data/lib/testcentricity_web/elements/cell_element.rb +62 -0
- data/lib/testcentricity_web/elements/cell_image.rb +8 -0
- data/lib/testcentricity_web/elements/cell_radio.rb +31 -0
- data/lib/testcentricity_web/elements/checkbox.rb +99 -0
- data/lib/testcentricity_web/elements/file_field.rb +45 -0
- data/lib/testcentricity_web/elements/image.rb +34 -0
- data/lib/testcentricity_web/elements/label.rb +8 -0
- data/lib/testcentricity_web/elements/link.rb +8 -0
- data/lib/testcentricity_web/elements/list.rb +54 -0
- data/lib/testcentricity_web/elements/list_button.rb +8 -0
- data/lib/testcentricity_web/elements/list_checkbox.rb +38 -0
- data/lib/testcentricity_web/elements/list_element.rb +51 -0
- data/lib/testcentricity_web/elements/list_radio.rb +31 -0
- data/lib/testcentricity_web/elements/radio.rb +73 -0
- data/lib/testcentricity_web/elements/select_list.rb +189 -0
- data/lib/testcentricity_web/elements/table.rb +473 -0
- data/lib/testcentricity_web/elements/textfield.rb +84 -0
- data/lib/testcentricity_web/environment.rb +249 -0
- data/lib/testcentricity_web/excel_helper.rb +242 -0
- data/lib/testcentricity_web/exception_queue_helper.rb +47 -0
- data/lib/testcentricity_web/page_objects_helper.rb +656 -0
- data/lib/testcentricity_web/page_sections_helper.rb +811 -0
- data/lib/testcentricity_web/siebel_open_ui_helper.rb +15 -0
- data/lib/testcentricity_web/ui_elements_helper.rb +425 -0
- data/lib/testcentricity_web/utility_helpers.rb +28 -0
- data/lib/testcentricity_web/version.rb +3 -0
- data/lib/testcentricity_web/webdriver_helper.rb +451 -0
- data/lib/testcentricity_web/world_extensions.rb +26 -0
- data/testcentricity_web.gemspec +42 -0
- metadata +52 -4
@@ -0,0 +1,451 @@
|
|
1
|
+
require 'selenium-webdriver'
|
2
|
+
require 'os'
|
3
|
+
|
4
|
+
|
5
|
+
module TestCentricity
|
6
|
+
module WebDriverConnect
|
7
|
+
include Capybara::DSL
|
8
|
+
|
9
|
+
def self.initialize_web_driver(app_host = nil)
|
10
|
+
Capybara.app_host = app_host unless app_host.nil?
|
11
|
+
browser = ENV['WEB_BROWSER']
|
12
|
+
|
13
|
+
# assume that we're testing within a local desktop web browser
|
14
|
+
Environ.platform = :desktop
|
15
|
+
Environ.browser = browser
|
16
|
+
Environ.device = false
|
17
|
+
Environ.device_type = 'browser'
|
18
|
+
|
19
|
+
case browser.downcase.to_sym
|
20
|
+
when :appium
|
21
|
+
initialize_appium
|
22
|
+
context = 'mobile device emulator'
|
23
|
+
when :browserstack
|
24
|
+
initialize_browserstack
|
25
|
+
context = 'Browserstack cloud service'
|
26
|
+
when :crossbrowser
|
27
|
+
initialize_crossbrowser
|
28
|
+
context = 'CrossBrowserTesting cloud service'
|
29
|
+
when :poltergeist
|
30
|
+
initialize_poltergeist
|
31
|
+
context = 'PhantomJS'
|
32
|
+
when :saucelabs
|
33
|
+
initialize_saucelabs
|
34
|
+
context = 'Sauce Labs cloud service'
|
35
|
+
when :testingbot
|
36
|
+
initialize_testingbot
|
37
|
+
context = 'TestingBot cloud service'
|
38
|
+
else
|
39
|
+
if ENV['SELENIUM'] == 'remote'
|
40
|
+
initialize_remote
|
41
|
+
context = 'Selenium Grid2'
|
42
|
+
else
|
43
|
+
initialize_local_browser
|
44
|
+
context = 'local instance'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# set browser window size only if testing with a desktop web browser
|
49
|
+
unless Environ.is_device? || Capybara.current_driver == :poltergeist
|
50
|
+
initialize_browser_size
|
51
|
+
end
|
52
|
+
|
53
|
+
puts "Using #{Environ.browser} browser via #{context}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.set_domain(url)
|
57
|
+
Capybara.app_host = url
|
58
|
+
end
|
59
|
+
|
60
|
+
# Set the WebDriver path for Chrome, IE, or Edge browsers
|
61
|
+
def self.set_webdriver_path(project_path)
|
62
|
+
path_to_driver = nil
|
63
|
+
# check for existence of /webdrivers or /features/support/drivers folders
|
64
|
+
base_path = 'features/support/drivers'
|
65
|
+
unless File.directory?(File.join(project_path, base_path))
|
66
|
+
base_path = 'webdrivers'
|
67
|
+
unless File.directory?(File.join(project_path, base_path))
|
68
|
+
raise 'Could not find WebDriver files in /webdrivers or /features/support/drivers folders'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
# set WebDriver path based on browser and operating system
|
72
|
+
case ENV['WEB_BROWSER'].downcase.to_sym
|
73
|
+
when :chrome
|
74
|
+
if OS.osx?
|
75
|
+
path_to_driver = 'mac/chromedriver'
|
76
|
+
elsif OS.windows?
|
77
|
+
path_to_driver = 'windows/chromedriver.exe'
|
78
|
+
end
|
79
|
+
Selenium::WebDriver::Chrome.driver_path = File.join(project_path, base_path, path_to_driver)
|
80
|
+
# when :firefox
|
81
|
+
# if OS.osx?
|
82
|
+
# path_to_driver = 'mac/geckodriver'
|
83
|
+
# elsif OS.windows?
|
84
|
+
# path_to_driver = 'windows/geckodriver.exe'
|
85
|
+
# end
|
86
|
+
# Selenium::WebDriver::Firefox.driver_path = File.join(project_path, base_path, path_to_driver)
|
87
|
+
when :ie
|
88
|
+
path_to_driver = 'windows/IEDriverServer.exe'
|
89
|
+
Selenium::WebDriver::IE.driver_path = File.join(project_path, base_path, path_to_driver)
|
90
|
+
when :edge
|
91
|
+
path_to_driver = 'windows/MicrosoftWebDriver.exe'
|
92
|
+
Selenium::WebDriver::Edge.driver_path = File.join(project_path, base_path, path_to_driver)
|
93
|
+
else
|
94
|
+
if ENV['HOST_BROWSER'] && ENV['HOST_BROWSER'].downcase.to_sym == :chrome
|
95
|
+
if OS.osx?
|
96
|
+
path_to_driver = 'mac/chromedriver'
|
97
|
+
elsif OS.windows?
|
98
|
+
path_to_driver = 'windows/chromedriver.exe'
|
99
|
+
end
|
100
|
+
Selenium::WebDriver::Chrome.driver_path = File.join(project_path, base_path, path_to_driver)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
puts "The webdriver path is: #{File.join(project_path, base_path, path_to_driver)}" unless path_to_driver.nil?
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def self.initialize_appium
|
109
|
+
Environ.device = true
|
110
|
+
Environ.platform = :mobile
|
111
|
+
Environ.device_type = ENV['APP_DEVICE']
|
112
|
+
Environ.device_os = ENV['APP_PLATFORM_NAME']
|
113
|
+
Environ.device_orientation = ENV['ORIENTATION'] if ENV['ORIENTATION']
|
114
|
+
Capybara.default_driver = :appium
|
115
|
+
endpoint = 'http://localhost:4723/wd/hub'
|
116
|
+
desired_capabilities = {
|
117
|
+
platformName: ENV['APP_PLATFORM_NAME'],
|
118
|
+
platformVersion: ENV['APP_VERSION'],
|
119
|
+
browserName: ENV['APP_BROWSER'],
|
120
|
+
deviceName: ENV['APP_DEVICE']
|
121
|
+
}
|
122
|
+
desired_capabilities['avd'] = ENV['APP_DEVICE'] if ENV['APP_PLATFORM_NAME'].downcase.to_sym == :android
|
123
|
+
desired_capabilities['orientation'] = ENV['ORIENTATION'].upcase if ENV['ORIENTATION']
|
124
|
+
desired_capabilities['udid'] = ENV['APP_UDID'] if ENV['APP_UDID']
|
125
|
+
desired_capabilities['safariInitialUrl'] = ENV['APP_INITIAL_URL'] if ENV['APP_INITIAL_URL']
|
126
|
+
desired_capabilities['safariAllowPopups'] = ENV['APP_ALLOW_POPUPS'] if ENV['APP_ALLOW_POPUPS']
|
127
|
+
desired_capabilities['safariIgnoreFraudWarning'] = ENV['APP_IGNORE_FRAUD_WARNING'] if ENV['APP_IGNORE_FRAUD_WARNING']
|
128
|
+
desired_capabilities['noReset'] = ENV['APP_NO_RESET'] if ENV['APP_NO_RESET']
|
129
|
+
desired_capabilities['locale'] = ENV['LOCALE'] if ENV['LOCALE']
|
130
|
+
|
131
|
+
Capybara.register_driver :appium do |app|
|
132
|
+
appium_lib_options = { server_url: endpoint }
|
133
|
+
all_options = {
|
134
|
+
appium_lib: appium_lib_options,
|
135
|
+
caps: desired_capabilities
|
136
|
+
}
|
137
|
+
Appium::Capybara::Driver.new app, all_options
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.initialize_local_browser
|
142
|
+
if OS.osx?
|
143
|
+
Environ.os = 'OS X'
|
144
|
+
elsif OS.windows?
|
145
|
+
Environ.os = 'Windows'
|
146
|
+
end
|
147
|
+
|
148
|
+
browser = ENV['WEB_BROWSER']
|
149
|
+
|
150
|
+
case browser.downcase.to_sym
|
151
|
+
when :firefox, :chrome, :ie, :safari, :edge
|
152
|
+
Environ.platform = :desktop
|
153
|
+
else
|
154
|
+
Environ.platform = :mobile
|
155
|
+
Environ.device_type = Browsers.mobile_device_name(browser)
|
156
|
+
end
|
157
|
+
|
158
|
+
Capybara.default_driver = :selenium
|
159
|
+
Capybara.register_driver :selenium do |app|
|
160
|
+
case browser.downcase.to_sym
|
161
|
+
when :ie, :safari, :edge
|
162
|
+
Capybara::Selenium::Driver.new(app, :browser => browser.to_sym)
|
163
|
+
|
164
|
+
when :firefox
|
165
|
+
if ENV['LOCALE']
|
166
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
167
|
+
profile['intl.accept_languages'] = ENV['LOCALE']
|
168
|
+
Capybara::Selenium::Driver.new(app, :profile => profile)
|
169
|
+
else
|
170
|
+
Capybara::Selenium::Driver.new(app, :browser => :firefox)
|
171
|
+
end
|
172
|
+
|
173
|
+
when :chrome
|
174
|
+
ENV['LOCALE'] ? args = ['--disable-infobars', "--lang=#{ENV['LOCALE']}"] : args = ['--disable-infobars']
|
175
|
+
Capybara::Selenium::Driver.new(app, :browser => :chrome, :args => args)
|
176
|
+
|
177
|
+
else
|
178
|
+
user_agent = Browsers.mobile_device_agent(browser)
|
179
|
+
ENV['HOST_BROWSER'] ? host_browser = ENV['HOST_BROWSER'].downcase.to_sym : host_browser = :firefox
|
180
|
+
case host_browser
|
181
|
+
when :firefox
|
182
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
183
|
+
profile['general.useragent.override'] = user_agent
|
184
|
+
profile['intl.accept_languages'] = ENV['LOCALE'] if ENV['LOCALE']
|
185
|
+
Capybara::Selenium::Driver.new(app, :profile => profile)
|
186
|
+
|
187
|
+
when :chrome
|
188
|
+
ENV['LOCALE'] ?
|
189
|
+
args = ["--user-agent='#{user_agent}'", "--lang=#{ENV['LOCALE']}", '--disable-infobars'] :
|
190
|
+
args = ["--user-agent='#{user_agent}'", '--disable-infobars']
|
191
|
+
Capybara::Selenium::Driver.new(app, :browser => :chrome, :args => args)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def self.initialize_browserstack
|
198
|
+
browser = ENV['BS_BROWSER']
|
199
|
+
|
200
|
+
if ENV['BS_REAL_MOBILE'] || ENV['BS_PLATFORM']
|
201
|
+
Environ.platform = :mobile
|
202
|
+
Environ.device = true
|
203
|
+
Environ.device_type = ENV['BS_DEVICE']
|
204
|
+
Environ.device_os = ENV['BS_OS']
|
205
|
+
Environ.device_orientation = ENV['ORIENTATION'] if ENV['ORIENTATION']
|
206
|
+
|
207
|
+
elsif ENV['BS_OS']
|
208
|
+
Environ.os = "#{ENV['BS_OS']} #{ENV['BS_OS_VERSION']}"
|
209
|
+
end
|
210
|
+
|
211
|
+
endpoint = "http://#{ENV['BS_USERNAME']}:#{ENV['BS_AUTHKEY']}@hub-cloud.browserstack.com/wd/hub"
|
212
|
+
Capybara.register_driver :browserstack do |app|
|
213
|
+
capabilities = Selenium::WebDriver::Remote::Capabilities.new
|
214
|
+
|
215
|
+
if ENV['BS_REAL_MOBILE']
|
216
|
+
capabilities['device'] = ENV['BS_DEVICE']
|
217
|
+
capabilities['realMobile'] = true
|
218
|
+
capabilities['os_version'] = ENV['BS_OS_VERSION']
|
219
|
+
|
220
|
+
elsif ENV['BS_PLATFORM']
|
221
|
+
capabilities[:platform] = ENV['BS_PLATFORM']
|
222
|
+
capabilities[:browserName] = browser
|
223
|
+
capabilities['device'] = ENV['BS_DEVICE'] if ENV['BS_DEVICE']
|
224
|
+
capabilities['deviceOrientation'] = ENV['ORIENTATION'] if ENV['ORIENTATION']
|
225
|
+
|
226
|
+
elsif ENV['BS_OS']
|
227
|
+
capabilities['os'] = ENV['BS_OS']
|
228
|
+
capabilities['os_version'] = ENV['BS_OS_VERSION']
|
229
|
+
capabilities['browser'] = browser || 'chrome'
|
230
|
+
capabilities['browser_version'] = ENV['BS_VERSION'] if ENV['BS_VERSION']
|
231
|
+
capabilities['resolution'] = ENV['RESOLUTION'] if ENV['RESOLUTION']
|
232
|
+
end
|
233
|
+
|
234
|
+
capabilities['browserstack.timezone'] = ENV['TIME_ZONE'] if ENV['TIME_ZONE']
|
235
|
+
capabilities['browserstack.video'] = ENV['RECORD_VIDEO'] if ENV['RECORD_VIDEO']
|
236
|
+
capabilities['browserstack.debug'] = 'true'
|
237
|
+
capabilities['project'] = ENV['AUTOMATE_PROJECT'] if ENV['AUTOMATE_PROJECT']
|
238
|
+
capabilities['build'] = ENV['AUTOMATE_BUILD'] if ENV['AUTOMATE_BUILD']
|
239
|
+
|
240
|
+
ENV['TEST_CONTEXT'] ?
|
241
|
+
context_message = "#{Environ.test_environment} - #{ENV['TEST_CONTEXT']}" :
|
242
|
+
context_message = Environ.test_environment
|
243
|
+
if ENV['PARALLEL']
|
244
|
+
thread_num = ENV['TEST_ENV_NUMBER']
|
245
|
+
thread_num = 1 if thread_num.blank?
|
246
|
+
context_message = "#{context_message} - Thread ##{thread_num}"
|
247
|
+
end
|
248
|
+
capabilities['name'] = context_message
|
249
|
+
|
250
|
+
capabilities['acceptSslCerts'] = 'true'
|
251
|
+
capabilities['browserstack.localIdentifier'] = ENV['BS_LOCAL_ID'] if ENV['BS_LOCAL_ID']
|
252
|
+
capabilities['browserstack.local'] = 'true' if ENV['TUNNELING']
|
253
|
+
|
254
|
+
case browser.downcase.to_sym
|
255
|
+
when :ie
|
256
|
+
capabilities['ie.ensureCleanSession'] = 'true'
|
257
|
+
capabilities['ie.browserCommandLineSwitches'] = 'true'
|
258
|
+
capabilities['nativeEvents'] = 'true'
|
259
|
+
when :safari
|
260
|
+
capabilities['cleanSession'] = 'true'
|
261
|
+
when :iphone, :ipad
|
262
|
+
capabilities['javascriptEnabled'] = 'true'
|
263
|
+
capabilities['cleanSession'] = 'true'
|
264
|
+
end
|
265
|
+
Capybara::Selenium::Driver.new(app, :browser => :remote, :url => endpoint, :desired_capabilities => capabilities)
|
266
|
+
end
|
267
|
+
|
268
|
+
Environ.browser = browser
|
269
|
+
|
270
|
+
Capybara.default_driver = :browserstack
|
271
|
+
Capybara.run_server = false
|
272
|
+
end
|
273
|
+
|
274
|
+
def self.initialize_crossbrowser
|
275
|
+
browser = ENV['CB_BROWSER']
|
276
|
+
|
277
|
+
if ENV['CB_OS']
|
278
|
+
Environ.os = ENV['CB_OS']
|
279
|
+
Environ.platform = :desktop
|
280
|
+
elsif ENV['CB_PLATFORM']
|
281
|
+
Environ.device_type = ENV['CB_PLATFORM']
|
282
|
+
Environ.device = true
|
283
|
+
Environ.platform = :mobile
|
284
|
+
end
|
285
|
+
|
286
|
+
endpoint = "http://#{ENV['CB_USERNAME']}:#{ENV['CB_AUTHKEY']}@hub.crossbrowsertesting.com:80/wd/hub"
|
287
|
+
Capybara.register_driver :crossbrowser do |app|
|
288
|
+
capabilities = Selenium::WebDriver::Remote::Capabilities.new
|
289
|
+
capabilities['name'] = ENV['AUTOMATE_PROJECT'] if ENV['AUTOMATE_PROJECT']
|
290
|
+
capabilities['build'] = ENV['AUTOMATE_BUILD'] if ENV['AUTOMATE_BUILD']
|
291
|
+
capabilities['browser_api_name'] = browser
|
292
|
+
capabilities['screen_resolution'] = ENV['RESOLUTION'] if ENV['RESOLUTION']
|
293
|
+
if ENV['CB_OS']
|
294
|
+
capabilities['os_api_name'] = ENV['CB_OS']
|
295
|
+
Environ.platform = :desktop
|
296
|
+
elsif ENV['CB_PLATFORM']
|
297
|
+
capabilities['os_api_name'] = ENV['CB_PLATFORM']
|
298
|
+
end
|
299
|
+
Capybara::Selenium::Driver.new(app, :browser => :remote, :url => endpoint, :desired_capabilities => capabilities)
|
300
|
+
end
|
301
|
+
|
302
|
+
Environ.browser = browser
|
303
|
+
|
304
|
+
Capybara.default_driver = :crossbrowser
|
305
|
+
Capybara.run_server = false
|
306
|
+
end
|
307
|
+
|
308
|
+
def self.initialize_poltergeist
|
309
|
+
if ENV['BROWSER_SIZE']
|
310
|
+
resolution = ENV['BROWSER_SIZE'].split(',')
|
311
|
+
width = resolution[0]
|
312
|
+
height = resolution[1]
|
313
|
+
else
|
314
|
+
width = 1650
|
315
|
+
height = 1000
|
316
|
+
end
|
317
|
+
Capybara.default_driver = :poltergeist
|
318
|
+
Capybara.register_driver :poltergeist do |app|
|
319
|
+
options = {
|
320
|
+
:js_errors => true,
|
321
|
+
:timeout => 120,
|
322
|
+
:debug => false,
|
323
|
+
:phantomjs_options => ['--load-images=no', '--disk-cache=false'],
|
324
|
+
:inspector => true,
|
325
|
+
:window_size => [width, height]
|
326
|
+
}
|
327
|
+
Capybara::Poltergeist::Driver.new(app, options)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
def self.initialize_remote
|
332
|
+
browser = ENV['WEB_BROWSER']
|
333
|
+
endpoint = ENV['REMOTE_ENDPOINT'] || 'http://127.0.0.1:4444/wd/hub'
|
334
|
+
capabilities = Selenium::WebDriver::Remote::Capabilities.send(browser.downcase.to_sym)
|
335
|
+
Capybara.register_driver :remote_browser do |app|
|
336
|
+
Capybara::Selenium::Driver.new(app, :browser => :remote, :url => endpoint, :desired_capabilities => capabilities)
|
337
|
+
end
|
338
|
+
Capybara.current_driver = :remote_browser
|
339
|
+
Capybara.default_driver = :remote_browser
|
340
|
+
end
|
341
|
+
|
342
|
+
def self.initialize_saucelabs
|
343
|
+
browser = ENV['SL_BROWSER']
|
344
|
+
|
345
|
+
if ENV['SL_OS']
|
346
|
+
Environ.platform = :desktop
|
347
|
+
Environ.os = ENV['SL_OS']
|
348
|
+
elsif ENV['SL_PLATFORM']
|
349
|
+
Environ.device_type = ENV['SL_DEVICE']
|
350
|
+
Environ.platform = :mobile
|
351
|
+
end
|
352
|
+
|
353
|
+
endpoint = "http://#{ENV['SL_USERNAME']}:#{ENV['SL_AUTHKEY']}@ondemand.saucelabs.com:80/wd/hub"
|
354
|
+
Capybara.register_driver :saucelabs do |app|
|
355
|
+
capabilities = Selenium::WebDriver::Remote::Capabilities.new
|
356
|
+
capabilities['name'] = ENV['AUTOMATE_PROJECT'] if ENV['AUTOMATE_PROJECT']
|
357
|
+
capabilities['build'] = ENV['AUTOMATE_BUILD'] if ENV['AUTOMATE_BUILD']
|
358
|
+
capabilities['browserName'] = browser
|
359
|
+
capabilities['version'] = ENV['SL_VERSION'] if ENV['SL_VERSION']
|
360
|
+
capabilities['screenResolution'] = ENV['RESOLUTION'] if ENV['RESOLUTION']
|
361
|
+
capabilities['recordVideo'] = ENV['RECORD_VIDEO'] if ENV['RECORD_VIDEO']
|
362
|
+
if ENV['SL_OS']
|
363
|
+
capabilities['platform'] = ENV['SL_OS']
|
364
|
+
elsif ENV['SL_PLATFORM']
|
365
|
+
capabilities['platform'] = ENV['SL_PLATFORM']
|
366
|
+
capabilities['deviceName'] = ENV['SL_DEVICE']
|
367
|
+
capabilities['deviceType'] = ENV['SL_DEVICE_TYPE'] if ENV['SL_DEVICE_TYPE']
|
368
|
+
capabilities['deviceOrientation'] = ENV['ORIENTATION'] if ENV['ORIENTATION']
|
369
|
+
end
|
370
|
+
|
371
|
+
Capybara::Selenium::Driver.new(app, :browser => :remote, :url => endpoint, :desired_capabilities => capabilities)
|
372
|
+
end
|
373
|
+
|
374
|
+
Environ.browser = browser
|
375
|
+
|
376
|
+
Capybara.default_driver = :saucelabs
|
377
|
+
Capybara.run_server = false
|
378
|
+
end
|
379
|
+
|
380
|
+
def self.initialize_testingbot
|
381
|
+
browser = ENV['TB_BROWSER']
|
382
|
+
|
383
|
+
Environ.os = ENV['TB_OS']
|
384
|
+
if ENV['TB_PLATFORM']
|
385
|
+
if ENV['ORIENTATION']
|
386
|
+
Environ.device_orientation = ENV['ORIENTATION']
|
387
|
+
end
|
388
|
+
Environ.device_os = ENV['TB_PLATFORM']
|
389
|
+
Environ.device_type = ENV['TB_DEVICE']
|
390
|
+
Environ.device = true
|
391
|
+
Environ.platform = :mobile
|
392
|
+
else
|
393
|
+
Environ.platform = :desktop
|
394
|
+
end
|
395
|
+
|
396
|
+
ENV['TUNNELING'] ?
|
397
|
+
endpoint = '@localhost:4445/wd/hub' :
|
398
|
+
endpoint = '@hub.testingbot.com:4444/wd/hub'
|
399
|
+
endpoint = "http://#{ENV['TB_USERNAME']}:#{ENV['TB_AUTHKEY']}#{endpoint}"
|
400
|
+
Capybara.register_driver :testingbot do |app|
|
401
|
+
capabilities = Selenium::WebDriver::Remote::Capabilities.new
|
402
|
+
capabilities['name'] = ENV['AUTOMATE_PROJECT'] if ENV['AUTOMATE_PROJECT']
|
403
|
+
capabilities['build'] = ENV['AUTOMATE_BUILD'] if ENV['AUTOMATE_BUILD']
|
404
|
+
capabilities['browserName'] = browser
|
405
|
+
capabilities['version'] = ENV['TB_VERSION'] if ENV['TB_VERSION']
|
406
|
+
capabilities['screen-resolution'] = ENV['RESOLUTION'] if ENV['RESOLUTION']
|
407
|
+
capabilities['platform'] = ENV['TB_OS']
|
408
|
+
capabilities['record_video'] = ENV['RECORD_VIDEO'] if ENV['RECORD_VIDEO']
|
409
|
+
if ENV['TB_PLATFORM']
|
410
|
+
if ENV['ORIENTATION']
|
411
|
+
capabilities['orientation'] = ENV['ORIENTATION']
|
412
|
+
end
|
413
|
+
capabilities['platformName'] = ENV['TB_PLATFORM']
|
414
|
+
capabilities['deviceName'] = ENV['TB_DEVICE']
|
415
|
+
end
|
416
|
+
|
417
|
+
Capybara::Selenium::Driver.new(app, :browser => :remote, :url => endpoint, :desired_capabilities => capabilities)
|
418
|
+
end
|
419
|
+
|
420
|
+
Environ.browser = browser
|
421
|
+
|
422
|
+
Capybara.default_driver = :testingbot
|
423
|
+
Capybara.run_server = false
|
424
|
+
|
425
|
+
end
|
426
|
+
|
427
|
+
def self.initialize_browser_size
|
428
|
+
# tile browser windows if running in multiple parallel threads and BROWSER_TILE environment variable is true
|
429
|
+
if ENV['PARALLEL'] && ENV['BROWSER_TILE']
|
430
|
+
thread = ENV['TEST_ENV_NUMBER'].to_i
|
431
|
+
if thread > 1
|
432
|
+
Browsers.set_browser_window_position(100 * thread - 1, 100 * thread - 1)
|
433
|
+
sleep(1)
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
browser = Environ.browser.to_s
|
438
|
+
if Environ.is_desktop?
|
439
|
+
if ENV['BROWSER_SIZE'] == 'max'
|
440
|
+
Browsers.maximize_browser
|
441
|
+
elsif ENV['BROWSER_SIZE']
|
442
|
+
Browsers.set_browser_window_size(ENV['BROWSER_SIZE'])
|
443
|
+
else
|
444
|
+
Browsers.set_browser_window_size(Browsers.browser_size(browser, ENV['ORIENTATION']))
|
445
|
+
end
|
446
|
+
elsif Environ.is_mobile? && !Environ.is_device?
|
447
|
+
Browsers.set_browser_window_size(Browsers.browser_size(browser, ENV['ORIENTATION']))
|
448
|
+
end
|
449
|
+
end
|
450
|
+
end
|
451
|
+
end
|