symbiont 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.hound.yml +76 -0
- data/.rspec +2 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +18 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +0 -3
- data/README.md +16 -8
- data/Rakefile +13 -2
- data/bin/console +2 -2
- data/lib/symbiont/accessor.rb +9 -9
- data/lib/symbiont/assertions.rb +33 -33
- data/lib/symbiont/data_builder.rb +35 -35
- data/lib/symbiont/data_reader.rb +20 -22
- data/lib/symbiont/data_setter.rb +39 -32
- data/lib/symbiont/elements.rb +186 -185
- data/lib/symbiont/errors.rb +9 -9
- data/lib/symbiont/factory.rb +75 -87
- data/lib/symbiont/helpers.rb +52 -50
- data/lib/symbiont/pages.rb +161 -164
- data/lib/symbiont/service_objects.rb +15 -15
- data/lib/symbiont/soap_methods.rb +47 -46
- data/lib/symbiont/version.rb +1 -1
- data/lib/symbiont.rb +28 -30
- data/symbiont.gemspec +7 -4
- metadata +53 -20
- data/lib/symbiont/workflows.rb +0 -88
data/lib/symbiont/pages.rb
CHANGED
@@ -1,164 +1,161 @@
|
|
1
|
-
module Symbiont
|
2
|
-
module Page
|
3
|
-
include Helpers
|
4
|
-
|
5
|
-
def view
|
6
|
-
no_url_is_provided if asserted_url.nil?
|
7
|
-
browser.goto(asserted_url)
|
8
|
-
self
|
9
|
-
end
|
10
|
-
|
11
|
-
def
|
12
|
-
no_url_matches_is_provided if url_match.nil?
|
13
|
-
!(browser.url =~ url_match).nil?
|
14
|
-
end
|
15
|
-
|
16
|
-
def
|
17
|
-
no_title_is_provided if asserted_title.nil?
|
18
|
-
!(browser.title.match(asserted_title)).nil?
|
19
|
-
end
|
20
|
-
|
21
|
-
def verified?
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
def asserted_url
|
27
|
-
self.class.asserted_url
|
28
|
-
end
|
29
|
-
|
30
|
-
def url_match
|
31
|
-
self.class.url_match
|
32
|
-
end
|
33
|
-
|
34
|
-
def asserted_title
|
35
|
-
self.class.asserted_title
|
36
|
-
end
|
37
|
-
|
38
|
-
def url
|
39
|
-
browser.url
|
40
|
-
end
|
41
|
-
|
42
|
-
def markup
|
43
|
-
browser.html
|
44
|
-
end
|
45
|
-
|
46
|
-
def text
|
47
|
-
browser.text
|
48
|
-
end
|
49
|
-
|
50
|
-
def title
|
51
|
-
browser.title
|
52
|
-
end
|
53
|
-
|
54
|
-
def visit(url)
|
55
|
-
browser.goto(url)
|
56
|
-
end
|
57
|
-
|
58
|
-
def screenshot(file)
|
59
|
-
browser.wd.save_screenshot(file)
|
60
|
-
end
|
61
|
-
|
62
|
-
def run_script(script, *args)
|
63
|
-
browser.execute_script(script, *args)
|
64
|
-
end
|
65
|
-
|
66
|
-
def get_cookie(name)
|
67
|
-
|
68
|
-
if cookie[:name] == name
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
#
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
alias_method :
|
151
|
-
alias_method :
|
152
|
-
alias_method :
|
153
|
-
alias_method :
|
154
|
-
alias_method :
|
155
|
-
alias_method :
|
156
|
-
alias_method :
|
157
|
-
alias_method :
|
158
|
-
alias_method :
|
159
|
-
alias_method :
|
160
|
-
|
161
|
-
|
162
|
-
alias_method :attach_to, :within_window
|
163
|
-
end
|
164
|
-
end
|
1
|
+
module Symbiont
|
2
|
+
module Page
|
3
|
+
include Helpers
|
4
|
+
|
5
|
+
def view
|
6
|
+
no_url_is_provided if asserted_url.nil?
|
7
|
+
browser.goto(asserted_url)
|
8
|
+
self
|
9
|
+
end
|
10
|
+
|
11
|
+
def correct_url?
|
12
|
+
no_url_matches_is_provided if url_match.nil?
|
13
|
+
!(browser.url =~ url_match).nil?
|
14
|
+
end
|
15
|
+
|
16
|
+
def correct_title?
|
17
|
+
no_title_is_provided if asserted_title.nil?
|
18
|
+
!(browser.title.match(asserted_title)).nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
def verified?
|
22
|
+
correct_url?
|
23
|
+
correct_title?
|
24
|
+
end
|
25
|
+
|
26
|
+
def asserted_url
|
27
|
+
self.class.asserted_url
|
28
|
+
end
|
29
|
+
|
30
|
+
def url_match
|
31
|
+
self.class.url_match
|
32
|
+
end
|
33
|
+
|
34
|
+
def asserted_title
|
35
|
+
self.class.asserted_title
|
36
|
+
end
|
37
|
+
|
38
|
+
def url
|
39
|
+
browser.url
|
40
|
+
end
|
41
|
+
|
42
|
+
def markup
|
43
|
+
browser.html
|
44
|
+
end
|
45
|
+
|
46
|
+
def text
|
47
|
+
browser.text
|
48
|
+
end
|
49
|
+
|
50
|
+
def title
|
51
|
+
browser.title
|
52
|
+
end
|
53
|
+
|
54
|
+
def visit(url)
|
55
|
+
browser.goto(url)
|
56
|
+
end
|
57
|
+
|
58
|
+
def screenshot(file)
|
59
|
+
browser.wd.save_screenshot(file)
|
60
|
+
end
|
61
|
+
|
62
|
+
def run_script(script, *args)
|
63
|
+
browser.execute_script(script, *args)
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_cookie(name)
|
67
|
+
browser.cookies.to_a.each do |cookie|
|
68
|
+
return cookie[:value] if cookie[:name] == name
|
69
|
+
end
|
70
|
+
nil
|
71
|
+
end
|
72
|
+
|
73
|
+
def clear_cookies
|
74
|
+
browser.cookies.clear
|
75
|
+
end
|
76
|
+
|
77
|
+
def refresh
|
78
|
+
browser.refresh
|
79
|
+
end
|
80
|
+
|
81
|
+
# @return [String] the message contained in the alert message box
|
82
|
+
def will_alert
|
83
|
+
yield
|
84
|
+
value = nil
|
85
|
+
if browser.alert.exists?
|
86
|
+
value = browser.alert.text
|
87
|
+
browser.alert.ok
|
88
|
+
end
|
89
|
+
value
|
90
|
+
end
|
91
|
+
|
92
|
+
# @param response [Boolean] true to accept confirmation, false to cancel it
|
93
|
+
# @return [String] the message contained in the confirmation message box
|
94
|
+
def will_confirm(response)
|
95
|
+
yield
|
96
|
+
value = nil
|
97
|
+
if browser.alert.exists?
|
98
|
+
value = browser.alert.text
|
99
|
+
response ? browser.alert.ok : browser.alert.close
|
100
|
+
end
|
101
|
+
value
|
102
|
+
end
|
103
|
+
|
104
|
+
# @param response [String] the value to be used in the prompt
|
105
|
+
# @return [Hash] :message for the prompt message, :default_value for
|
106
|
+
# the value that the prompt had before the response was applied
|
107
|
+
def will_prompt(response)
|
108
|
+
cmd = "window.prompt = function(text, value) \
|
109
|
+
{window.__lastWatirPrompt = {message: text, default_value: value}; \
|
110
|
+
return '#{response}';}"
|
111
|
+
browser.wd.execute_script(cmd)
|
112
|
+
yield
|
113
|
+
result = browser.wd.execute_script('return window.__lastWatirPrompt')
|
114
|
+
result && result.dup.each_key { |k| result[k.to_sym] = result.delete(k) }
|
115
|
+
result
|
116
|
+
end
|
117
|
+
|
118
|
+
# Used to identify a web element or action on a web element as existing
|
119
|
+
# within an enclosing window object. The window can be referenced using
|
120
|
+
# either the title attribute of the window or a direct URL. The URL does
|
121
|
+
# not have to be the entire URL; it can just be a page name.
|
122
|
+
#
|
123
|
+
# @param locator [Hash] the :title or :url of the window
|
124
|
+
# @param block [Proc] any code that should be executed as an
|
125
|
+
# action on or within the window
|
126
|
+
def within_window(locator, &block)
|
127
|
+
identifier = { locator.keys.first => /#{Regexp.escape(locator.values.first)}/ }
|
128
|
+
browser.window(identifier).use(&block)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Used to identify a web element as existing within an enclosing object
|
132
|
+
# like a modal dialog box. What this does is override the normal call to
|
133
|
+
# showModalDialog and opens a window instead. In order to use this new
|
134
|
+
# window, you have to attach to it.
|
135
|
+
def within_modal
|
136
|
+
convert_modal_to_window = %{
|
137
|
+
window.showModalDialog = function(sURL, vArguments, sFeatures) {
|
138
|
+
window.dialogArguments = vArguments;
|
139
|
+
modalWin = window.open(sURL, 'modal', sFeatures);
|
140
|
+
return modalWin;
|
141
|
+
}
|
142
|
+
}
|
143
|
+
browser.execute_script(convert_modal_to_window)
|
144
|
+
yield if block_given?
|
145
|
+
end
|
146
|
+
|
147
|
+
alias_method :current_url, :url
|
148
|
+
alias_method :page_url, :url
|
149
|
+
alias_method :html, :markup
|
150
|
+
alias_method :page_text, :text
|
151
|
+
alias_method :page_title, :title
|
152
|
+
alias_method :navigate_to, :visit
|
153
|
+
alias_method :goto, :visit
|
154
|
+
alias_method :save_screenshot, :screenshot
|
155
|
+
alias_method :execute_script, :run_script
|
156
|
+
alias_method :remove_cookies, :clear_cookies
|
157
|
+
alias_method :refresh_page, :refresh
|
158
|
+
alias_method :select_window, :within_window
|
159
|
+
alias_method :attach_to, :within_window
|
160
|
+
end
|
161
|
+
end
|
@@ -14,7 +14,7 @@ module Symbiont
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def connected?
|
17
|
-
|
17
|
+
!@client.nil?
|
18
18
|
end
|
19
19
|
|
20
20
|
def operations
|
@@ -47,7 +47,7 @@ module Symbiont
|
|
47
47
|
operation = args.shift
|
48
48
|
message = args.shift
|
49
49
|
type = message.is_a?(String) ? :xml : :message
|
50
|
-
call(operation,
|
50
|
+
call(operation, type => message)
|
51
51
|
end
|
52
52
|
|
53
53
|
def call(operation, data)
|
@@ -58,21 +58,21 @@ module Symbiont
|
|
58
58
|
def client_properties
|
59
59
|
properties = { log: false, ssl_version: :SSLv3, ssl_verify_mode: :none }
|
60
60
|
[
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
61
|
+
:has_wsdl,
|
62
|
+
:has_proxy,
|
63
|
+
:has_basic_auth,
|
64
|
+
:has_digest_auth,
|
65
|
+
:has_encoding,
|
66
|
+
:has_soap_header,
|
67
|
+
:has_open_timeout,
|
68
|
+
:has_read_timeout,
|
69
|
+
:has_log_level,
|
70
|
+
:has_ssl_version,
|
71
|
+
:has_ssl_verification,
|
72
72
|
].each do |sym|
|
73
|
-
properties = properties.merge(
|
73
|
+
properties = properties.merge(send sym) if self.respond_to? sym
|
74
74
|
end
|
75
75
|
properties
|
76
76
|
end
|
77
77
|
end
|
78
|
-
end
|
78
|
+
end
|
@@ -1,72 +1,73 @@
|
|
1
|
-
module Symbiont
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
module Symbiont
|
2
|
+
module SoapObject
|
3
|
+
module SoapMethods
|
4
|
+
def wsdl(url)
|
5
|
+
define_method(:has_wsdl) do
|
6
|
+
@wsdl ||= url
|
7
|
+
{ wsdl: @wsdl }
|
8
|
+
end
|
7
9
|
end
|
8
|
-
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def proxy(url)
|
12
|
+
define_method(:has_proxy) do
|
13
|
+
{ proxy: url }
|
14
|
+
end
|
13
15
|
end
|
14
|
-
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def basic_auth(*creds)
|
18
|
+
define_method(:has_basic_auth) do
|
19
|
+
{ basic_auth: creds }
|
20
|
+
end
|
19
21
|
end
|
20
|
-
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
def digest_auth(*creds)
|
24
|
+
define_method(:has_digest_auth) do
|
25
|
+
{ digest_auth: creds }
|
26
|
+
end
|
25
27
|
end
|
26
|
-
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
def soap_header(header)
|
30
|
+
define_method(:has_soap_header) do
|
31
|
+
{ soap_header: header }
|
32
|
+
end
|
31
33
|
end
|
32
|
-
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
def encoding(enc)
|
36
|
+
define_method(:has_encoding) do
|
37
|
+
{ encoding: enc }
|
38
|
+
end
|
37
39
|
end
|
38
|
-
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
def open_timeout(timeout)
|
42
|
+
define_method(:has_open_timeout) do
|
43
|
+
{ open_timeout: timeout }
|
44
|
+
end
|
43
45
|
end
|
44
|
-
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
def read_timeout(timeout)
|
48
|
+
define_method(:has_read_timeout) do
|
49
|
+
{ read_timeout: timeout }
|
50
|
+
end
|
49
51
|
end
|
50
|
-
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
def log_level(level)
|
54
|
+
define_method(:has_log_level) do
|
55
|
+
{ log: true, log_level: level, pretty_print_xml: true }
|
56
|
+
end
|
55
57
|
end
|
56
|
-
end
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
def ssl_version(version)
|
60
|
+
define_method(:has_ssl_version) do
|
61
|
+
{ ssl_version: version }
|
62
|
+
end
|
61
63
|
end
|
62
|
-
end
|
63
64
|
|
64
|
-
|
65
|
-
|
65
|
+
def ssl_verification(enable)
|
66
|
+
return unless enable
|
66
67
|
define_method(:has_ssl_verification) do
|
67
68
|
{ ssl_verify_mode: true }
|
68
69
|
end
|
69
70
|
end
|
70
71
|
end
|
71
72
|
end
|
72
|
-
end
|
73
|
+
end
|
data/lib/symbiont/version.rb
CHANGED
data/lib/symbiont.rb
CHANGED
@@ -12,7 +12,6 @@ require 'symbiont/assertions'
|
|
12
12
|
require 'symbiont/pages'
|
13
13
|
require 'symbiont/elements'
|
14
14
|
require 'symbiont/accessor'
|
15
|
-
require 'symbiont/workflows'
|
16
15
|
require 'symbiont/factory'
|
17
16
|
|
18
17
|
require 'symbiont/data_reader'
|
@@ -26,25 +25,22 @@ module Symbiont
|
|
26
25
|
def self.included(caller)
|
27
26
|
caller.extend Symbiont::Assertion
|
28
27
|
caller.extend Symbiont::Element
|
29
|
-
|
30
28
|
caller.send :include, Symbiont::Page
|
31
29
|
caller.send :include, Symbiont::Accessor
|
32
|
-
|
33
30
|
caller.send :include, Symbiont::DataSetter
|
34
31
|
caller.send :include, Symbiont::DataBuilder
|
35
|
-
|
36
32
|
Symbiont.trace("#{caller.class} #{caller} has attached the Symbiont.")
|
37
33
|
end
|
38
34
|
|
39
35
|
def self.trace(message, level = 1)
|
40
36
|
puts '*' * level + " #{message}" if ENV['SYMBIONT_TRACE'] == 'on'
|
41
37
|
end
|
42
|
-
|
43
|
-
def self.
|
38
|
+
|
39
|
+
def self.browser=(browser)
|
44
40
|
@browser = browser
|
45
41
|
end
|
46
|
-
|
47
|
-
def self.
|
42
|
+
|
43
|
+
def self.browser
|
48
44
|
@browser
|
49
45
|
end
|
50
46
|
|
@@ -52,48 +48,50 @@ module Symbiont
|
|
52
48
|
attr_reader :browser
|
53
49
|
|
54
50
|
# @param browser [Object] a tool driver instance
|
55
|
-
def initialize(browser=nil)
|
51
|
+
def initialize(browser = nil)
|
56
52
|
Symbiont.trace("Symbiont attached to browser:\n\t#{browser.inspect}")
|
57
|
-
|
58
|
-
@browser = Symbiont.
|
59
|
-
@browser = browser if Symbiont.
|
53
|
+
|
54
|
+
@browser = Symbiont.browser unless Symbiont.browser.nil?
|
55
|
+
@browser = browser if Symbiont.browser.nil?
|
60
56
|
|
61
57
|
initialize_page if respond_to?(:initialize_page)
|
62
58
|
initialize_activity if respond_to?(:initialize_activity)
|
63
59
|
end
|
64
|
-
end
|
65
60
|
|
66
|
-
def
|
67
|
-
|
61
|
+
def self.set_browser(app = :firefox)
|
62
|
+
@browser = Watir::Browser.new(app)
|
63
|
+
Symbiont.browser = @browser
|
64
|
+
end
|
68
65
|
end
|
69
66
|
|
70
|
-
def
|
71
|
-
|
72
|
-
Symbiont.driver = @browser
|
67
|
+
def attach(mod = Symbiont)
|
68
|
+
include mod
|
73
69
|
end
|
74
70
|
|
75
|
-
alias :symbiont_browser_for :symbiont_browser
|
76
|
-
|
77
71
|
class Object
|
78
|
-
def call_method_chain(method_chain, arg=nil)
|
72
|
+
def call_method_chain(method_chain, arg = nil)
|
79
73
|
return self if method_chain.empty?
|
80
|
-
method_chain.split('.').inject(self)
|
74
|
+
method_chain.split('.').inject(self) do |o, m|
|
81
75
|
if arg.nil?
|
82
76
|
o.send(m.intern)
|
83
77
|
else
|
84
78
|
o.send(m.intern, arg)
|
85
79
|
end
|
86
|
-
|
80
|
+
end
|
87
81
|
end
|
88
82
|
end
|
89
83
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
84
|
+
module Watir
|
85
|
+
class CheckBox
|
86
|
+
alias_method :check, :set
|
87
|
+
alias_method :uncheck, :clear
|
88
|
+
alias_method :checked?, :set?
|
89
|
+
end
|
94
90
|
end
|
95
91
|
|
96
|
-
|
97
|
-
|
98
|
-
|
92
|
+
module Watir
|
93
|
+
class Radio
|
94
|
+
alias_method :choose, :set
|
95
|
+
alias_method :chosen?, :set?
|
96
|
+
end
|
99
97
|
end
|
data/symbiont.gemspec
CHANGED
@@ -30,17 +30,20 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.bindir = 'exe'
|
31
31
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
32
|
spec.require_paths = ['lib']
|
33
|
+
spec.requirements << 'Watir-WebDriver, Savon'
|
33
34
|
|
34
35
|
spec.required_ruby_version = '>= 2.0'
|
35
36
|
spec.required_rubygems_version = '>= 1.8.29'
|
36
37
|
|
37
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
38
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
38
39
|
spec.add_development_dependency 'rake', '~> 10.0'
|
39
|
-
spec.add_development_dependency 'rspec'
|
40
|
+
spec.add_development_dependency 'rspec'
|
40
41
|
spec.add_development_dependency 'pry'
|
42
|
+
spec.add_development_dependency 'simplecov'
|
43
|
+
spec.add_development_dependency 'rubocop'
|
41
44
|
|
42
|
-
spec.add_runtime_dependency 'colorize'
|
43
|
-
spec.add_runtime_dependency 'watir-webdriver'
|
45
|
+
spec.add_runtime_dependency 'colorize'
|
46
|
+
spec.add_runtime_dependency 'watir-webdriver'
|
44
47
|
spec.add_runtime_dependency 'watir-dom-wait'
|
45
48
|
spec.add_runtime_dependency 'watir-scroll'
|
46
49
|
spec.add_runtime_dependency 'savon'
|