gridium 1.0.24 → 1.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/driver.rb +39 -38
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3efaf9febdf9bc0da0a30c30a82b915e0a1af9d
4
- data.tar.gz: 5a3ec90a3de58bf7b373f98736490274a32bfbd0
3
+ metadata.gz: 0c4000b1d9492350bd2822865345f7ea075f4a21
4
+ data.tar.gz: b0fe0e9605f43905fd72d3eebec8fa8e35e543fb
5
5
  SHA512:
6
- metadata.gz: 6338fc6be0c1e94b86c5b61cdf5e461cbecdac78c9502a64299df6ee42e809a0e6fa1b819c1d04b65fd321a1201fcbee7b024f6692c34366e399917865ba7b3d
7
- data.tar.gz: 46da65c5ba22643281eeac7b4fbbbd0b1ddb0c489c61709d988055936c004aa968e99075f7e2bfe62cc3f363702122d2c0099d29a93a1f907e7db1e2cd934ed4
6
+ metadata.gz: c4b2a1943330d58b59e3e303da9e1230922fc672a807c727d4931eef9b94381c59bbae8f14836bede3fd2be6b78caa023be79b3c3842edd7021da0c1fcdc8a53
7
+ data.tar.gz: 783500fba46309e94a3c708856626880d683a275a3fd21fc035d3c59dc15e5dea106b83287a73319e793208bded616ecf4fc006767fe41dcff3741e12180bebe
@@ -6,7 +6,7 @@ class Driver
6
6
  @@driver = nil
7
7
 
8
8
  def self.reset
9
- Log.debug("====> Driver.reset: #{@@driver}")
9
+ Log.debug("[Gridium::Driver] Driver.reset: #{@@driver}")
10
10
  driver.manage.delete_all_cookies
11
11
  driver.manage.timeouts.page_load = Gridium.config.page_load_timeout
12
12
  driver.manage.timeouts.implicit_wait = Gridium.config.element_timeout
@@ -27,12 +27,12 @@ class Driver
27
27
  def self.driver
28
28
  begin
29
29
  unless @@driver
30
- Log.debug("=====> Driver.driver: instantiating new driver")
30
+ Log.debug("[Gridium::Driver] Driver.driver: instantiating new driver")
31
31
  @browser_type = Gridium.config.browser
32
32
  ##Adding support for remote browsers
33
33
  if Gridium.config.browser_source == :remote
34
34
  @@driver = Selenium::WebDriver.for(:remote, url: Gridium.config.target_environment, desired_capabilities: Gridium.config.browser)
35
- Log.debug("Remote Browser Requested: #{@@driver}")
35
+ Log.debug("[Gridium::Driver] Remote Browser Requested: #{@@driver}")
36
36
  #this file detector is only used for remote drivers and is needed to upload files from test_host through Grid to browser
37
37
  @@driver.file_detector = lambda do |args|
38
38
  str = args.first.to_s
@@ -45,19 +45,19 @@ class Driver
45
45
  #do stuff
46
46
  s3_project_folder = Gridium.config.project_name_for_s3
47
47
  s3_subfolder = Gridium.config.subdirectory_name_for_s3
48
- Log.debug("configuring s3 to save files to this directory: #{s3_project_folder} in addition to being saved locally")
48
+ Log.debug("[Gridium::Driver] configuring s3 to save files to this directory: #{s3_project_folder} in addition to being saved locally")
49
49
  @s3 = Gridium::GridiumS3.new(s3_project_folder, s3_subfolder)
50
- Log.debug("s3 is #{@s3}")
50
+ Log.debug("[Gridium::Driver] s3 is #{@s3}")
51
51
  else
52
- Log.debug("s3 screenshots not enabled in spec_helper; they will be only be saved locally")
52
+ Log.debug("[Gridium::Driver] s3 screenshots not enabled in spec_helper; they will be only be saved locally")
53
53
  @s3 = nil
54
54
  end
55
55
  reset
56
56
  end
57
57
  @@driver
58
58
  rescue Exception => e
59
- Log.debug(e.backtrace.inspect)
60
- Log.info("Driver did not load within (#{Gridium.config.page_load_timeout}) seconds. [#{e.message}]")
59
+ Log.debug("[Gridium::Driver] #{e.backtrace.inspect}")
60
+ Log.info("[Gridium::Driver] Driver did not load within (#{Gridium.config.page_load_timeout}) seconds. [#{e.message}]")
61
61
  $fail_test_instantly = true
62
62
  Kernel.fail(e.message)
63
63
  end
@@ -79,32 +79,33 @@ class Driver
79
79
  # =============== #
80
80
 
81
81
  def self.visit(path)
82
- Log.debug("====> Driver.Visit: #{@@driver}")
82
+ Log.debug("[Gridium::Driver] Driver.Visit: #{@@driver}")
83
83
  begin
84
84
  if path
85
- Log.debug("Navigating to url: (#{path}).")
85
+ Log.debug("[Gridium::Driver] Navigating to url: (#{path}).")
86
86
  driver
87
87
  time_start = Time.now
88
88
  driver.navigate.to(path)
89
89
  time_end = Time.new
90
90
  page_load = (time_end - time_start)
91
- Log.debug("Page loaded in (#{page_load}) seconds.")
91
+ Log.debug("[Gridium::Driver] Page loaded in (#{page_load}) seconds.")
92
92
  $verification_passes += 1
93
93
  end
94
- rescue Exception => e
95
- Log.debug(e.backtrace.inspect)
96
- Log.error("#{e.message} - Also be sure to check the url formatting. http:// is required for proper test execution (www is optional).")
94
+ rescue Selenium::WebDriver::Error::ScriptTimeoutError => e
95
+ Log.debug("[Gridium::Driver] #{e.backtrace.inspect}")
96
+ Log.error("[Gridium::Driver] Timed out attempting to load #{path} for #{Gridium.config.page_load_timeout} seconds:\n#{e.message}\n - Also be sure to check the url formatting. http:// is required for proper test execution (www is optional).")
97
+ raise e
97
98
  end
98
99
  end
99
100
 
100
101
  def self.nav(path)
101
- Log.debug("====> Driver.nav: #{@@driver}")
102
+ Log.debug("[Gridium::Driver] Driver.nav: #{@@driver}")
102
103
  visit(Gridium.config.url + path)
103
104
  end
104
105
 
105
106
  def self.quit
106
107
  if @@driver
107
- Log.debug('Shutting down web driver...')
108
+ Log.debug('[Gridium::Driver] Shutting down web driver...')
108
109
  @@driver.quit
109
110
  @@driver = nil
110
111
  end
@@ -141,22 +142,22 @@ class Driver
141
142
  domain = URI.parse(site_url)
142
143
  host = domain.host
143
144
  if (!host.nil?)
144
- Log.debug("Current domain is: (#{host}).")
145
+ Log.debug("[Gridium::Driver] Current domain is: (#{host}).")
145
146
  return host
146
147
  else
147
- Log.error("Unable to parse URL.")
148
+ Log.error("[Gridium::Driver] Unable to parse URL.")
148
149
  end
149
150
  end
150
151
 
151
152
  def self.verify_url(given_url)
152
- Log.debug('Verifying URL...')
153
+ Log.debug('[Gridium::Driver] Verifying URL...')
153
154
  current_url = self.current_url.to_s
154
155
  current_domain = self.current_domain.to_s
155
156
  if current_url.include?(given_url)
156
- Log.debug("Confirmed. (#{current_url}) includes (#{given_url}).")
157
+ Log.debug("[Gridium::Driver] Confirmed. (#{current_url}) includes (#{given_url}).")
157
158
  $verification_passes += 1
158
159
  else
159
- Log.error("(#{current_url}) does not include (#{given_url}).")
160
+ Log.error("[Gridium::Driver] (#{current_url}) does not include (#{given_url}).")
160
161
  end
161
162
  end
162
163
 
@@ -194,7 +195,7 @@ class Driver
194
195
  end
195
196
 
196
197
  def self.save_screenshot(type = 'saved')
197
- Log.debug ("Capturing screenshot of browser...")
198
+ Log.debug ("[Gridium::Driver] Capturing screenshot of browser...")
198
199
  timestamp = Time.now.strftime("%Y_%m_%d__%H_%M_%S")
199
200
  screenshot_path = File.join($current_run_dir, "screenshot__#{timestamp}__#{type}.png")
200
201
  driver.save_screenshot(screenshot_path)
@@ -206,71 +207,71 @@ class Driver
206
207
  def self._save_to_s3_if_configured(screenshot_path)
207
208
  if Gridium.config.screenshots_to_s3
208
209
  url = @s3.save_file(screenshot_path)
209
- Log.info("#{screenshot_path} saved to #{url}")
210
+ Log.info("[Gridium::Driver] #{screenshot_path} saved to #{url}")
210
211
  end
211
212
  end
212
213
 
213
214
 
214
215
  def self.list_open_windows
215
216
  handles = driver.window_handles
216
- Log.debug("List of active windows:")
217
+ Log.debug("[Gridium::Driver] List of active windows:")
217
218
  handles.each do |handle|
218
219
  driver.switch_to.window(handle)
219
- Log.debug("| Window with title: (#{driver.title}) and handle: #{handle} is currently open.")
220
+ Log.debug("[Gridium::Driver] Window with title: (#{driver.title}) and handle: #{handle} is currently open.")
220
221
  end
221
222
  driver.switch_to.window(driver.window_handles.first)
222
223
  end
223
224
 
224
225
  def self.open_new_window(url)
225
- Log.debug("Opening new window and loading url (#{url})...")
226
+ Log.debug("[Gridium::Driver] Opening new window and loading url (#{url})...")
226
227
  DriverExtensions.open_new_window(url)
227
228
  end
228
229
 
229
230
  def self.close_window
230
- Log.debug("Closing window (#{driver.title})...")
231
+ Log.debug("[Gridium::Driver] Closing window (#{driver.title})...")
231
232
  DriverExtensions.close_window
232
233
  end
233
234
 
234
235
  def self.switch_to_window(title)
235
236
  current_title = driver.title
236
- Log.debug("Current window is: (#{current_title}). Switching to next window (#{title})...")
237
+ Log.debug("[Gridium::Driver] Current window is: (#{current_title}). Switching to next window (#{title})...")
237
238
  handles = driver.window_handles
238
239
  driver.switch_to.window(handles.first)
239
240
  handles.each do |handle|
240
241
  driver.switch_to.window(handle)
241
242
  if driver.title == title
242
- Log.debug("Window (#{driver.title}) is now the active window.")
243
+ Log.debug("[Gridium::Driver] Window (#{driver.title}) is now the active window.")
243
244
  return
244
245
  end
245
246
  end
246
247
  list_open_windows
247
- Log.error("Unable to switch to window with title (#{title}).")
248
+ Log.error("[Gridium::Driver] Unable to switch to window with title (#{title}).")
248
249
  end
249
250
 
250
251
  def self.switch_to_next_window
251
252
  current_title = driver.title
252
- Log.debug("Current window is: (#{current_title}). Switching to next window...")
253
+ Log.debug("[Gridium::Driver] Current window is: (#{current_title}). Switching to next window...")
253
254
  driver.switch_to.window(driver.window_handles.last)
254
- Log.debug("Window (#{driver.title}) is now the active window.")
255
+ Log.debug("[Gridium::Driver] Window (#{driver.title}) is now the active window.")
255
256
  end
256
257
 
257
258
  def self.switch_to_main_window
258
259
  current_title = driver.title
259
- Log.debug("Current window is: (#{current_title}). Switching to main window...")
260
+ Log.debug("[Gridium::Driver] Current window is: (#{current_title}). Switching to main window...")
260
261
  driver.switch_to.window(driver.window_handles.first)
261
- Log.debug("Window (#{driver.title}) is now the active window.")
262
+ Log.debug("[Gridium::Driver] Window (#{driver.title}) is now the active window.")
262
263
  end
263
264
 
264
265
  def self.switch_to_frame(by, locator)
265
- Log.debug("Attempting to switch to Frame at: #{locator}")
266
+ Log.debug("[Gridium::Driver] Attempting to switch to Frame at: #{locator}")
266
267
  driver.switch_to.frame(driver.find_element(by, locator))
267
- Log.debug("Frame at: #{locator} is now active frame!")
268
+ Log.debug("[Gridium::Driver] Frame at: #{locator} is now active frame!")
268
269
  end
269
270
 
270
271
  def self.switch_to_parent_frame
271
- Log.debug("Switching back to main parent frame")
272
+ Log.debug("[Gridium::Driver] Switching back to main parent frame")
272
273
  driver.switch_to.parent_frame
273
- Log.debug("Now back to Parent Frame")
274
+ Log.debug("[Gridium::Driver] Now back to Parent Frame")
274
275
  end
275
276
 
276
277
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gridium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.24
4
+ version: 1.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Urban
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-14 00:00:00.000000000 Z
11
+ date: 2017-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler