webdrone 0.8.4 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffeb0f5e4c60f6cc3ecd900650712fd6e38f9a71
4
- data.tar.gz: 27921c8433aa30ac2f44d40e59cffcfc0e815656
3
+ metadata.gz: 61c793edbf7d6662b79f4f592da8880a52cbdfa1
4
+ data.tar.gz: 4d4741dd41ae4fcbba0d78e925f86611e687831b
5
5
  SHA512:
6
- metadata.gz: 93ab6cba56cef4059d166dddd7c2b0f33d99fec060f429516fa0f1c81e757f49e7e1dbd4c9dfecf18e2e4b212095a884d1823489a14e40ac27e81e2cfa54b8e4
7
- data.tar.gz: 00a7c07aff97b1540419dbac9b8093a331756c24ba5a1ad10927768497486e9431f134a8a25aff436110c173265ac0adf0db81d3c25acecf33578c40dd7819d4
6
+ metadata.gz: 0e3ae4aae152bcb9964330b789ad386c5a6034db4eca402f7ed777988818e270034c0146409c3f6265cf1ad709bee58806c8267fc442c65717f67ef55db47c4a
7
+ data.tar.gz: 93f3359c20cd90e8b5c16dfb45318ae0f5e434b1554af73d6335e94d53b54e2b8cd3e4b033fe12859e6a39c8853d35189cf369ab19734ebfd64218e8d517b8ac
@@ -25,7 +25,7 @@ module Webdrone
25
25
  @@chrome_prefs
26
26
  end
27
27
 
28
- def initialize(browser: 'chrome', create_outdir: true, outdir: nil, timeout:, maximize: true, chrome_prefs: nil, firefox_profile: nil)
28
+ def initialize(browser: 'chrome', create_outdir: true, outdir: nil, timeout:, maximize: true, error: :raise_report, chrome_prefs: nil, firefox_profile: nil)
29
29
  if create_outdir or outdir
30
30
  outdir ||= File.join("webdrone_output", Time.new.strftime('%Y%m%d_%H%M%S'))
31
31
  self.conf.outdir = outdir
@@ -49,6 +49,7 @@ module Webdrone
49
49
  else
50
50
  @driver = Selenium::WebDriver.for browser.to_sym
51
51
  end
52
+ self.conf.error = error
52
53
  self.conf.timeout = timeout if timeout
53
54
  self.maximize if maximize
54
55
  end
data/lib/webdrone/conf.rb CHANGED
@@ -6,11 +6,12 @@ module Webdrone
6
6
  end
7
7
 
8
8
  class Conf
9
- attr_accessor :a0, :timeout, :outdir
9
+ attr_accessor :a0, :timeout, :outdir, :error
10
10
 
11
11
  def initialize(a0)
12
12
  @a0 = a0
13
13
  @outdir = "."
14
+ @error = :raise_report
14
15
  end
15
16
 
16
17
  def timeout=(val)
@@ -26,5 +27,12 @@ module Webdrone
26
27
  rescue => exception
27
28
  Webdrone.report_error(@a0, exception, Kernel.caller_locations)
28
29
  end
30
+
31
+ def error=(val)
32
+ raise "Invalid value '#{val}' for error" if not [:raise_report, :raise, :ignore].include? val
33
+ @error = val
34
+ rescue => exception
35
+ Webdrone.report_error(@a0, exception, Kernel.caller_locations)
36
+ end
29
37
  end
30
38
  end
data/lib/webdrone/ctxt.rb CHANGED
@@ -46,7 +46,7 @@ module Webdrone
46
46
 
47
47
  def reset
48
48
  @a0.driver.switch_to.default_content
49
- @ramestack = []
49
+ @framestack = []
50
50
  rescue => exception
51
51
  Webdrone.report_error(@a0, exception, Kernel.caller_locations)
52
52
  end
@@ -64,5 +64,22 @@ module Webdrone
64
64
  rescue => exception
65
65
  Webdrone.report_error(@a0, exception, Kernel.caller_locations)
66
66
  end
67
+
68
+ def with_conf(new_config)
69
+ current_config = {}
70
+
71
+ new_config.each do |k, v|
72
+ current_config[k] = @a0.conf.send k
73
+ @a0.conf.send "#{k}=", v
74
+ end
75
+
76
+ yield
77
+ rescue => exception
78
+ Webdrone.report_error(@a0, exception, Kernel.caller_locations)
79
+ ensure
80
+ current_config.each do |k, v|
81
+ @a0.conf.send "#{k}=", v
82
+ end
83
+ end
67
84
  end
68
85
  end
@@ -10,17 +10,14 @@ module Webdrone
10
10
 
11
11
  begin
12
12
  # find location of user error
13
- @caller_locations[1..-1].each do |location|
14
- if not location.path.include? 'lib/webdrone/'
13
+ @caller_locations[0..-1].each do |location|
14
+ if Gem.path.none? { |path| location.path.include? path }
15
15
  @location = location
16
16
  break
17
17
  end
18
18
  end
19
19
 
20
- report_script
21
- report_screenshot
22
- report_exception
23
- report_time
20
+ report if a0.conf.error == :raise_report
24
21
  rescue
25
22
  end
26
23
  end
@@ -47,6 +44,13 @@ module Webdrone
47
44
  @buffer = []
48
45
  end
49
46
 
47
+ def report
48
+ report_script
49
+ report_screenshot
50
+ report_exception
51
+ report_time
52
+ end
53
+
50
54
  def report_script
51
55
  begin
52
56
  ini, fin = [@location.lineno - 10 - 1, @location.lineno + 10 - 1]
@@ -104,10 +108,8 @@ module Webdrone
104
108
  end
105
109
 
106
110
  def self.report_error(a0, exception, caller_locations)
107
- if exception.class == WebdroneError
108
- raise exception
109
- end
110
-
111
- raise WebdroneError.new(exception.message, exception, a0, caller_locations)
111
+ exception = WebdroneError.new(exception.message, exception, a0, caller_locations) if exception.class != WebdroneError
112
+
113
+ raise exception if a0.conf.error == :raise or a0.conf.error == :raise_report
112
114
  end
113
115
  end
data/lib/webdrone/open.rb CHANGED
@@ -17,5 +17,11 @@ module Webdrone
17
17
  rescue => exception
18
18
  Webdrone.report_error(@a0, exception, Kernel.caller_locations)
19
19
  end
20
+
21
+ def reload
22
+ @a0.driver.navigate.refresh
23
+ rescue => exception
24
+ Webdrone.report_error(@a0, exception, Kernel.caller_locations)
25
+ end
20
26
  end
21
27
  end
@@ -1,3 +1,3 @@
1
1
  module Webdrone
2
- VERSION = "0.8.4"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webdrone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldrin Martoq
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-17 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler