watchdoge 0.1.24 → 0.1.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/watchdoge/configuration.rb +20 -7
- data/lib/watchdoge/regression.rb +7 -4
- data/lib/watchdoge/regression/dsl.rb +13 -6
- data/lib/watchdoge/worker.rb +10 -13
- data/watchdoge.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82f7faeabe1627ca97fb027c5b6dd4273d89f992a5f838a514b0df8202182382
|
4
|
+
data.tar.gz: 71d1cf9249ecb4696afdca3b815ed0c718f9a704010a245957cb1d1ecff8d480
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9fc30e9d5ccc14002589d234f1a838fcde272179966c6589829b4c56a509c3611ce085626560a1325cba14c327fc8cb6c26c019c4185f9e417aadcc71c470f0
|
7
|
+
data.tar.gz: 7a0a333d68d915e269ea86b8955649463e2f288ff140ff094a91efa7816b44d558191cacdd0e473a012bceeef0dc04063f2235fd037e9602532e9c91683d72b6
|
@@ -33,9 +33,10 @@ module WatchDoge
|
|
33
33
|
attr_accessor :web_drivers_dir
|
34
34
|
|
35
35
|
attr_accessor :engine
|
36
|
-
attr_accessor :browser
|
37
36
|
attr_accessor :cookie_pool
|
38
|
-
|
37
|
+
|
38
|
+
attr_reader :default_worker_options
|
39
|
+
attr_accessor :worker_options
|
39
40
|
|
40
41
|
attr_accessor :notifications
|
41
42
|
|
@@ -65,15 +66,27 @@ module WatchDoge
|
|
65
66
|
# framwork that Worker used, default to selenium
|
66
67
|
@engine = Watir::Browser
|
67
68
|
|
68
|
-
#
|
69
|
-
@
|
69
|
+
# options for worker
|
70
|
+
@default_worker_options = {
|
71
|
+
# default window-size of worker
|
72
|
+
width: 1280,
|
73
|
+
height: 768,
|
74
|
+
|
75
|
+
# using Firfox as default browser
|
76
|
+
browser: :firefox,
|
77
|
+
|
78
|
+
# default to headless
|
79
|
+
headless: true,
|
80
|
+
|
81
|
+
# connection timeout threshold(seconds)
|
82
|
+
timeout: 120
|
83
|
+
}
|
84
|
+
|
85
|
+
@worker_options = {}
|
70
86
|
|
71
87
|
# where all cookie saved (as yaml)
|
72
88
|
@cookie_pool = @base_dir + '/.doge_cookie'
|
73
89
|
|
74
|
-
# connection timeout threshold(seconds)
|
75
|
-
@http_timeout = 120
|
76
|
-
|
77
90
|
# map of notification sources
|
78
91
|
# key: must be stringify of its class name
|
79
92
|
# value: hash struct, will passed to constructor while push message
|
data/lib/watchdoge/regression.rb
CHANGED
@@ -23,17 +23,17 @@ module WatchDoge
|
|
23
23
|
WatchDoge.hooks.before_regression.each { |t| instance_exec &t }
|
24
24
|
|
25
25
|
Dir["#{WatchDoge::Regression::Utils.scenarios_dir}/*"].each do |scenario_path|
|
26
|
-
WatchDoge.hooks.before_scenario.each { |t| instance_exec &t }
|
27
|
-
|
28
26
|
mgr = self.new scenario_path, regression_flag: regression_flag
|
29
27
|
|
28
|
+
WatchDoge.hooks.before_scenario.each { |t| mgr.instance_exec &t }
|
29
|
+
|
30
30
|
if WatchDoge.hooks.around_scenario
|
31
31
|
WatchDoge.hooks.around_scenario.call(Proc.new { mgr.eval_scenario })
|
32
32
|
else
|
33
33
|
mgr.eval_scenario
|
34
34
|
end
|
35
35
|
|
36
|
-
WatchDoge.hooks.after_scenario.each { |t| instance_exec &t }
|
36
|
+
WatchDoge.hooks.after_scenario.each { |t| mgr.instance_exec &t }
|
37
37
|
end
|
38
38
|
|
39
39
|
WatchDoge.hooks.after_regression.each { |t| instance_exec &t }
|
@@ -49,7 +49,10 @@ module WatchDoge
|
|
49
49
|
@setup_proc = nil
|
50
50
|
@teardown_proc = nil
|
51
51
|
|
52
|
-
|
52
|
+
worker_options =
|
53
|
+
WatchDoge.configuration.default_worker_options.merge WatchDoge.configuration.worker_options
|
54
|
+
|
55
|
+
@worker = WatchDoge::Worker.new @scenario_name, worker_options.dup
|
53
56
|
|
54
57
|
@view_port = {}
|
55
58
|
end
|
@@ -13,7 +13,14 @@ module WatchDoge
|
|
13
13
|
def use browser
|
14
14
|
puts "[use] browser #{browser}"
|
15
15
|
@worker.close
|
16
|
-
|
16
|
+
|
17
|
+
worker_options =
|
18
|
+
WatchDoge.configuration.default_worker_options.merge WatchDoge.configuration.worker_options
|
19
|
+
|
20
|
+
worker_options = worker_options.dup
|
21
|
+
worker_options[:browser] = browser
|
22
|
+
|
23
|
+
@worker = WatchDoge::Worker.new @scenario_name, worker_options
|
17
24
|
end
|
18
25
|
|
19
26
|
def sign_in_as resoruce
|
@@ -42,20 +49,20 @@ module WatchDoge
|
|
42
49
|
@setup_proc.call if @setup_proc
|
43
50
|
|
44
51
|
args = {
|
45
|
-
|
52
|
+
wait: nil
|
46
53
|
}.merge(kwargs)
|
47
54
|
|
48
|
-
args[:before].call if args[:before]
|
49
|
-
|
50
55
|
@worker.goto path
|
51
56
|
|
52
|
-
if
|
57
|
+
if args[:wait]
|
53
58
|
@view_port.merge!({
|
54
|
-
wait:
|
59
|
+
wait: args[:wait]
|
55
60
|
})
|
56
61
|
end
|
57
62
|
|
58
63
|
@worker.resize_by_viewport(@view_port) do
|
64
|
+
yield(@worker) if block_given?
|
65
|
+
|
59
66
|
case @regression_flag
|
60
67
|
when :capture
|
61
68
|
puts " -> make reference images on worker #{@worker}"
|
data/lib/watchdoge/worker.rb
CHANGED
@@ -20,27 +20,24 @@ module WatchDoge
|
|
20
20
|
# 2. height: browser's height, default to 768
|
21
21
|
# 3. http_client: instance of Selenium::WebDriver::Remote::Http
|
22
22
|
# 4. all acceptable arguments of Watir::Browser class
|
23
|
-
def initialize uid, options
|
23
|
+
def initialize uid, options
|
24
24
|
@http = Selenium::WebDriver::Remote::Http::Default.new
|
25
|
-
@browser = WatchDoge.configuration.browser
|
26
25
|
|
27
26
|
# HTTP timeout default to 120 sec
|
28
|
-
@http.read_timeout = options.delete(:timeout)
|
27
|
+
@http.read_timeout = options.delete(:timeout)
|
29
28
|
|
30
|
-
@
|
29
|
+
@browser = options[:browser]
|
31
30
|
|
32
|
-
|
33
|
-
width: 1280,
|
34
|
-
height: 768,
|
35
|
-
headless: true,
|
31
|
+
@uid = uid
|
36
32
|
|
33
|
+
options = {
|
37
34
|
# Selenium HTTP configuration
|
38
35
|
http_client: @http
|
39
|
-
}.merge(options).merge(
|
36
|
+
}.merge(options).merge(default_browser_profile)
|
40
37
|
|
41
38
|
# intall required version driver
|
42
39
|
WatchDoge::WebdriverManager.new @browser
|
43
|
-
@core = WatchDoge.configuration.engine.new @browser,
|
40
|
+
@core = WatchDoge.configuration.engine.new @browser, options
|
44
41
|
|
45
42
|
# for generate uri hash
|
46
43
|
@landed_page = nil
|
@@ -52,8 +49,8 @@ module WatchDoge
|
|
52
49
|
@cookie_loaded = false
|
53
50
|
|
54
51
|
# width/height
|
55
|
-
@width =
|
56
|
-
@height =
|
52
|
+
@width = options[:width]
|
53
|
+
@height = options[:height]
|
57
54
|
@core.window.resize_to @width, @height
|
58
55
|
end
|
59
56
|
|
@@ -105,7 +102,7 @@ module WatchDoge
|
|
105
102
|
|
106
103
|
private
|
107
104
|
|
108
|
-
def
|
105
|
+
def default_browser_profile
|
109
106
|
case @browser
|
110
107
|
when :chrome
|
111
108
|
prefs = {}
|
data/watchdoge.gemspec
CHANGED