rudra 1.1.1 → 1.1.2

This diff has not been reviewed by any users.
Log in in order to be able to vote.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rudra.rb +24 -15
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff3f69221a8e01fb0c0bf5a517c11547872f475b4cdc7aa551a26f81929c8373
4
- data.tar.gz: e039db5f85576af890d9b58f8deed4f7f30cf09ea474d8b2226c6574cad9c115
3
+ metadata.gz: f6485433a80329770ea6ce43647f1d10176c20fa1eefa825b51e222615e0b4fe
4
+ data.tar.gz: 980b66578597240fab1f2b0c68ee9fcc68be47b7466a8b5d99decf3dec6787c4
5
5
  SHA512:
6
- metadata.gz: a632f5ee68fa9417a78e86642246c47d2b4480292ca4816471b8f948458d7c6444150ccb7eb1a65fe8d7167f25dca32e1271f97cd725dbc86643362d763d4361
7
- data.tar.gz: 9edc12b61b22302ef0d80698a682d859a124acaa7c3d121d87353f83c84fef948f9fa93971ce85074c4b7faf52b27bf9ebef4bdedcb14429a8ef7222b73854f3
6
+ metadata.gz: f12e6ea46bb610708c6fa9cf13cd897bbd2e19ea645d7f5e748b1daccac7efdf00470b8333f16907401c9e63968f975f2c526188513862197db8771669e7c785
7
+ data.tar.gz: 7584799d278830b5912e6eb57e6582c3b2b7bb93cafff6c2bbc331137b06181674f5152e3cf179696ff3d1c6b66d0a91546fbd5800e2329662e5bb95357a8f40
@@ -292,13 +292,16 @@ class Rudra
292
292
  # Save a PNG screenshot to file
293
293
  # @param [String] filename the filename of PNG screenshot
294
294
  def save_screenshot(filename)
295
- mkdir(@screen_dir) unless Dir.exist?(@screen_dir)
296
- driver.save_screenshot(
297
- File.join(
298
- @screen_dir,
299
- filename.end_with?('.png') ? filename : "#{filename}.png"
300
- )
295
+ file = File.join(
296
+ @screen_dir,
297
+ sanitize(filename.end_with?('.png') ? filename : "#{filename}.png")
301
298
  )
299
+
300
+ dir = File.dirname(file)
301
+
302
+ mkdir(dir) unless Dir.exist?(dir)
303
+
304
+ driver.save_screenshot(file)
302
305
  end
303
306
 
304
307
  # Switch to the currently active modal dialog
@@ -370,24 +373,22 @@ class Rudra
370
373
  # @param [String, Selenium::WebDriver::Element] locator the locator to
371
374
  # identify the element or Selenium::WebDriver::Element
372
375
  # @param [Integer] seconds seconds before timed out
373
- def wait_for_not_visible(locator, seconds = 2)
376
+ def wait_for_not_visible(locator, seconds = 3)
374
377
  how, what = parse_locator(locator)
375
378
 
379
+ implicit_wait(seconds)
380
+
376
381
  begin
377
382
  wait_for(seconds) do
378
- begin
379
- elements = driver.find_elements(how, what)
380
- elements.empty? || elements.map(&:displayed?).none?
381
- rescue Selenium::WebDriver::Error::NoSuchElementError
382
- true
383
- rescue Selenium::WebDriver::Error::StaleElementReferenceError
384
- false
385
- end
383
+ elements = driver.find_elements(how, what)
384
+ elements.empty? || elements.map(&:displayed?).none?
386
385
  end
387
386
  rescue Selenium::WebDriver::Error::TimeoutError
388
387
  true
389
388
  rescue Net::ReadTimeout
390
389
  true
390
+ ensure
391
+ implicit_wait(timeout)
391
392
  end
392
393
  end
393
394
 
@@ -1305,6 +1306,14 @@ class Rudra
1305
1306
  )
1306
1307
  end
1307
1308
 
1309
+ def sanitize(filename)
1310
+ invalid_characters = ['/', '\\', '?', '%', '*', ':', '|', '"', '<', '>']
1311
+ invalid_characters.each do |character|
1312
+ filename.gsub!(character, '')
1313
+ end
1314
+ filename
1315
+ end
1316
+
1308
1317
  def random_id(length = 8)
1309
1318
  charset = [(0..9), ('a'..'z')].flat_map(&:to_a)
1310
1319
  id = Array.new(length) { charset.sample }.join
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Chen