fluent 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +21 -0
- data/lib/fluent.rb +29 -2
- data/lib/fluent/enclosers.rb +35 -0
- data/lib/fluent/evaluators.rb +82 -0
- data/lib/fluent/factory.rb +31 -0
- data/lib/fluent/generators.rb +116 -18
- data/lib/fluent/platform_selenium.rb +18 -0
- data/lib/fluent/platform_selenium/platform_object.rb +21 -0
- data/lib/fluent/platform_watir/platform_object.rb +181 -14
- data/lib/fluent/platform_watir/platform_web_elements/checkbox.rb +21 -0
- data/lib/fluent/platform_watir/platform_web_elements/radio.rb +21 -0
- data/lib/fluent/platform_watir/platform_web_elements/select_list.rb +30 -4
- data/lib/fluent/platform_watir/platform_web_elements/text_field.rb +13 -0
- data/lib/fluent/platform_watir/platform_web_elements/web_element.rb +84 -5
- data/lib/fluent/platforms.rb +2 -1
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/web_elements/cell.rb +16 -0
- data/lib/fluent/web_elements/checkbox.rb +4 -0
- data/lib/fluent/web_elements/div.rb +16 -0
- data/lib/fluent/web_elements/list_item.rb +16 -0
- data/lib/fluent/web_elements/ordered_list.rb +16 -0
- data/lib/fluent/web_elements/radio.rb +4 -0
- data/lib/fluent/web_elements/select_list.rb +4 -0
- data/lib/fluent/web_elements/span.rb +16 -0
- data/lib/fluent/web_elements/table.rb +16 -0
- data/lib/fluent/web_elements/text_area.rb +16 -0
- data/lib/fluent/web_elements/text_field.rb +8 -0
- data/lib/fluent/web_elements/unordered_list.rb +16 -0
- data/lib/fluent/web_elements/web_element.rb +12 -0
- data/spec/enclosers_spec.rb +38 -0
- data/spec/evaluators_spec.rb +88 -0
- data/spec/factory_spec.rb +42 -0
- data/spec/fluent_spec.rb +32 -1
- data/spec/generators/cell_generators_spec.rb +50 -0
- data/spec/generators/div_generators_spec.rb +49 -0
- data/spec/generators/list_item_generators_spec.rb +53 -0
- data/spec/generators/ordered_list_generators_spec.rb +53 -0
- data/spec/generators/span_generators_spec.rb +49 -0
- data/spec/generators/table_generators_spec.rb +49 -0
- data/spec/generators/text_area_generators_spec.rb +55 -0
- data/spec/generators/unordered_list_generators_spec.rb +53 -0
- data/spec/generators_spec.rb +40 -0
- data/spec/mock_app.rb +17 -0
- data/spec/platform_object_spec.rb +9 -0
- data/spec/web_element_spec.rb +15 -0
- data/spec/web_element_watir_spec.rb +123 -5
- data/spec/web_elements/checkbox_spec.rb +21 -0
- data/spec/web_elements/radio_spec.rb +21 -0
- data/spec/web_elements/select_list_spec.rb +41 -0
- data/spec/web_elements/text_field_spec.rb +16 -0
- metadata +48 -2
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fluent
|
2
|
+
module Platforms
|
3
|
+
module SeleniumWebDriver
|
4
|
+
|
5
|
+
def self.create_platform_object_for(browser)
|
6
|
+
require 'fluent/platform_selenium/platform_object'
|
7
|
+
return SeleniumWebDriver::PlatformObject.new(browser)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.works_with?(browser)
|
11
|
+
browser.is_a?(::Selenium::WebDriver::Driver)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Fluent::Platforms.register(:selenium_webdriver, Fluent::Platforms::SeleniumWebDriver)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fluent
|
2
|
+
module Platforms
|
3
|
+
module SeleniumWebDriver
|
4
|
+
class PlatformObject
|
5
|
+
|
6
|
+
attr_reader :browser
|
7
|
+
|
8
|
+
def initialize(browser)
|
9
|
+
@browser = browser
|
10
|
+
end
|
11
|
+
|
12
|
+
## Browser-Level Actions ##
|
13
|
+
|
14
|
+
def visit(url)
|
15
|
+
browser.navigate.to(url)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -15,6 +15,75 @@ module Fluent
|
|
15
15
|
browser.goto(url)
|
16
16
|
end
|
17
17
|
|
18
|
+
def url
|
19
|
+
browser.url
|
20
|
+
end
|
21
|
+
|
22
|
+
def remove_cookies
|
23
|
+
browser.cookies.clear
|
24
|
+
end
|
25
|
+
|
26
|
+
def refresh
|
27
|
+
browser.refresh
|
28
|
+
end
|
29
|
+
|
30
|
+
def run_script(script)
|
31
|
+
browser.execute_script(script)
|
32
|
+
end
|
33
|
+
|
34
|
+
def screenshot(file)
|
35
|
+
browser.wd.save_screenshot(file)
|
36
|
+
end
|
37
|
+
|
38
|
+
## Page-Level Actions ##
|
39
|
+
|
40
|
+
def markup
|
41
|
+
browser.html
|
42
|
+
end
|
43
|
+
|
44
|
+
def title
|
45
|
+
browser.title
|
46
|
+
end
|
47
|
+
|
48
|
+
def text
|
49
|
+
browser.text
|
50
|
+
end
|
51
|
+
|
52
|
+
def wait_until(timeout, message='wait condition was not found', &block)
|
53
|
+
browser.wait_until(timeout, message, &block)
|
54
|
+
end
|
55
|
+
|
56
|
+
## Encloser Actions ##
|
57
|
+
|
58
|
+
def will_alert(&block)
|
59
|
+
yield
|
60
|
+
value = nil
|
61
|
+
if browser.alert.exists?
|
62
|
+
value = browser.alert.text
|
63
|
+
browser.alert.ok
|
64
|
+
end
|
65
|
+
value
|
66
|
+
end
|
67
|
+
|
68
|
+
def will_confirm(response, &block)
|
69
|
+
yield
|
70
|
+
value = nil
|
71
|
+
if browser.alert.exists?
|
72
|
+
value = browser.alert.text
|
73
|
+
response ? browser.alert.ok : browser.alert.close
|
74
|
+
end
|
75
|
+
value
|
76
|
+
end
|
77
|
+
|
78
|
+
def will_prompt(response, &block)
|
79
|
+
cmd = "window.prompt = function(text, value) {window.__lastWatirPrompt = {message: text, default_value: value}; return #{!!response};}"
|
80
|
+
browser.wd.execute_script(cmd)
|
81
|
+
yield
|
82
|
+
result = browser.wd.execute_script('return window.__lastWatirPrompt')
|
83
|
+
result && result.dup.each_key { |k| result[k.to_sym] = result.delete(k) }
|
84
|
+
result
|
85
|
+
end
|
86
|
+
|
18
87
|
## Generator Actions ##
|
19
88
|
|
20
89
|
def link(locator)
|
@@ -22,7 +91,7 @@ module Fluent
|
|
22
91
|
end
|
23
92
|
|
24
93
|
def link_click(locator)
|
25
|
-
|
94
|
+
access_web_element('link(locator).click', locator)
|
26
95
|
end
|
27
96
|
|
28
97
|
def button(locator)
|
@@ -30,7 +99,7 @@ module Fluent
|
|
30
99
|
end
|
31
100
|
|
32
101
|
def button_click(locator)
|
33
|
-
|
102
|
+
access_web_element('button(locator).click', locator)
|
34
103
|
end
|
35
104
|
|
36
105
|
def text_field(locator)
|
@@ -38,11 +107,23 @@ module Fluent
|
|
38
107
|
end
|
39
108
|
|
40
109
|
def text_field_set(locator, value)
|
41
|
-
|
110
|
+
access_web_element('text_field(locator).set(value)', locator, value)
|
42
111
|
end
|
43
112
|
|
44
113
|
def text_field_get(locator)
|
45
|
-
|
114
|
+
access_web_element('text_field(locator).value', locator)
|
115
|
+
end
|
116
|
+
|
117
|
+
def text_area(locator)
|
118
|
+
reference_web_element('text_area(locator)', WebElements::TextArea, locator)
|
119
|
+
end
|
120
|
+
|
121
|
+
def text_area_set(locator, value)
|
122
|
+
access_web_element('text_area(locator).set(value)', locator, value)
|
123
|
+
end
|
124
|
+
|
125
|
+
def text_area_get(locator)
|
126
|
+
access_web_element('text_area(locator).value', locator)
|
46
127
|
end
|
47
128
|
|
48
129
|
def checkbox(locator)
|
@@ -50,15 +131,15 @@ module Fluent
|
|
50
131
|
end
|
51
132
|
|
52
133
|
def checkbox_check_state(locator)
|
53
|
-
|
134
|
+
access_web_element('checkbox(locator).set?', locator)
|
54
135
|
end
|
55
136
|
|
56
137
|
def checkbox_check(locator)
|
57
|
-
|
138
|
+
access_web_element('checkbox(locator).set', locator)
|
58
139
|
end
|
59
140
|
|
60
141
|
def checkbox_uncheck(locator)
|
61
|
-
|
142
|
+
access_web_element('checkbox(locator).clear', locator)
|
62
143
|
end
|
63
144
|
|
64
145
|
def select_list(locator)
|
@@ -66,15 +147,15 @@ module Fluent
|
|
66
147
|
end
|
67
148
|
|
68
149
|
def select_list_get_selected(locator)
|
69
|
-
|
150
|
+
access_web_element('select_list(locator).selected_options[0].text', locator)
|
70
151
|
end
|
71
152
|
|
72
153
|
def select_list_set(locator, value)
|
73
|
-
|
154
|
+
access_web_element('select_list(locator).select(value)', locator, value)
|
74
155
|
end
|
75
156
|
|
76
157
|
def select_list_get_value(locator)
|
77
|
-
|
158
|
+
access_web_element('select_list(locator).value', locator)
|
78
159
|
end
|
79
160
|
|
80
161
|
def radio(locator)
|
@@ -82,11 +163,11 @@ module Fluent
|
|
82
163
|
end
|
83
164
|
|
84
165
|
def radio_select(locator)
|
85
|
-
|
166
|
+
access_web_element('radio(locator).set', locator)
|
86
167
|
end
|
87
168
|
|
88
169
|
def radio_check_state(locator)
|
89
|
-
|
170
|
+
access_web_element('radio(locator).set?', locator)
|
90
171
|
end
|
91
172
|
|
92
173
|
def paragraph(locator)
|
@@ -94,13 +175,99 @@ module Fluent
|
|
94
175
|
end
|
95
176
|
|
96
177
|
def paragraph_text(locator)
|
97
|
-
|
178
|
+
access_web_element('p(locator).text', locator)
|
179
|
+
end
|
180
|
+
|
181
|
+
def div(locator)
|
182
|
+
reference_web_element('div(locator)', WebElements::Div, locator)
|
183
|
+
end
|
184
|
+
|
185
|
+
def div_text(locator)
|
186
|
+
access_web_element('div(locator).text', locator)
|
187
|
+
end
|
188
|
+
|
189
|
+
def span(locator)
|
190
|
+
reference_web_element('span(locator)', WebElements::Span, locator)
|
191
|
+
end
|
192
|
+
|
193
|
+
def span_text(locator)
|
194
|
+
access_web_element('span(locator).text', locator)
|
195
|
+
end
|
196
|
+
|
197
|
+
def ordered_list(locator)
|
198
|
+
reference_web_element('ol(locator)', WebElements::OrderedList, locator)
|
199
|
+
end
|
200
|
+
|
201
|
+
def ordered_list_text(locator)
|
202
|
+
access_web_element('ol(locator).text', locator)
|
203
|
+
end
|
204
|
+
|
205
|
+
def unordered_list(locator)
|
206
|
+
reference_web_element('ul(locator)', WebElements::UnorderedList, locator)
|
207
|
+
end
|
208
|
+
|
209
|
+
def unordered_list_text(locator)
|
210
|
+
access_web_element('ul(locator).text', locator)
|
211
|
+
end
|
212
|
+
|
213
|
+
def list_item(locator)
|
214
|
+
reference_web_element('li(locator)', WebElements::ListItem, locator)
|
215
|
+
end
|
216
|
+
|
217
|
+
def list_item_text(locator)
|
218
|
+
access_web_element('li(locator).text', locator)
|
219
|
+
end
|
220
|
+
|
221
|
+
def table(locator)
|
222
|
+
reference_web_element('table(locator)', WebElements::Table, locator)
|
223
|
+
end
|
224
|
+
|
225
|
+
def table_text(locator)
|
226
|
+
access_web_element('table(locator).text', locator)
|
227
|
+
end
|
228
|
+
|
229
|
+
def cell(locator)
|
230
|
+
reference_web_element('td(locator)', WebElements::Cell, locator)
|
231
|
+
end
|
232
|
+
|
233
|
+
def cell_text(locator)
|
234
|
+
access_web_element('td(locator).text', locator)
|
98
235
|
end
|
99
236
|
|
237
|
+
# This method is called by any platform methods that require getting
|
238
|
+
# an object reference.
|
239
|
+
#
|
240
|
+
# @param action [String] the driver logic to be sent to the browser
|
241
|
+
# @param object [Object] the type of web object that will receive the action
|
242
|
+
# @param locator [Hash] the specific web object selector
|
243
|
+
# @return [Object] the web object identified by the action
|
100
244
|
def reference_web_element(action, object, locator)
|
101
|
-
|
245
|
+
encloser = locator.delete(:frame)
|
246
|
+
element_object = browser.instance_eval("#{enclosed_by(encloser)}#{action}")
|
102
247
|
object.new(element_object, :platform => :watir_webdriver)
|
103
248
|
end
|
249
|
+
|
250
|
+
# This method is called by any platform methods that require accessing
|
251
|
+
# a web object with the intent of manipulating it or getting information
|
252
|
+
# from it.
|
253
|
+
#
|
254
|
+
# @param action [String] the driver logic to be sent to the browser
|
255
|
+
# @param locator [Hash] the specific web object selector
|
256
|
+
# @param value [String] any specific information that must be sent to the web object
|
257
|
+
# @return [Any] the information or object returned by the action
|
258
|
+
def access_web_element(action, locator, value=nil)
|
259
|
+
encloser = locator.delete(:frame)
|
260
|
+
browser.instance_eval("#{enclosed_by(encloser)}#{action}")
|
261
|
+
end
|
262
|
+
|
263
|
+
def enclosed_by(encloser)
|
264
|
+
return if encloser.nil?
|
265
|
+
|
266
|
+
key = encloser[0].keys.first
|
267
|
+
value = encloser[0].values.first
|
268
|
+
|
269
|
+
"frame(:#{key} => '#{value}')."
|
270
|
+
end
|
104
271
|
|
105
272
|
end
|
106
273
|
end
|
@@ -3,6 +3,36 @@ module Fluent
|
|
3
3
|
module WatirWebDriver
|
4
4
|
module SelectList
|
5
5
|
|
6
|
+
def select(value)
|
7
|
+
web_element.select(value)
|
8
|
+
end
|
9
|
+
|
10
|
+
def select_value(value)
|
11
|
+
web_element.select_value(value)
|
12
|
+
end
|
13
|
+
|
14
|
+
def selected?(value)
|
15
|
+
web_element.selected? value
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Array] array of strings representing the text of the currently selected options
|
19
|
+
def selected_options
|
20
|
+
web_element.selected_options.map { |e| e.text }.compact
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Array] array of strings representing the value of the currently selected options
|
24
|
+
def selected_values
|
25
|
+
web_element.selected_options.map { |e| e.value }.compact
|
26
|
+
end
|
27
|
+
|
28
|
+
def include?(value)
|
29
|
+
web_element.include? value
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns an object representing the option for the index provided.
|
33
|
+
# The index is zero-based.
|
34
|
+
#
|
35
|
+
# @return [Object] Fluent::WebElements::Option
|
6
36
|
def [](index)
|
7
37
|
::Fluent::WebElements::Option.new(options[index], :platform => :watir_webdriver)
|
8
38
|
end
|
@@ -20,10 +50,6 @@ module Fluent
|
|
20
50
|
elements
|
21
51
|
end
|
22
52
|
|
23
|
-
def option_xpath
|
24
|
-
'.//child::option'
|
25
|
-
end
|
26
|
-
|
27
53
|
end
|
28
54
|
end
|
29
55
|
end
|
@@ -2,11 +2,7 @@ module Fluent
|
|
2
2
|
module Platforms
|
3
3
|
module WatirWebDriver
|
4
4
|
module WebElement
|
5
|
-
|
6
|
-
def text
|
7
|
-
web_element.text
|
8
|
-
end
|
9
|
-
|
5
|
+
|
10
6
|
def exists?
|
11
7
|
web_element.exists?
|
12
8
|
end
|
@@ -15,6 +11,89 @@ module Fluent
|
|
15
11
|
web_element.present?
|
16
12
|
end
|
17
13
|
|
14
|
+
def double_click
|
15
|
+
web_element.double_click
|
16
|
+
end
|
17
|
+
|
18
|
+
def clear
|
19
|
+
web_element.clear
|
20
|
+
end
|
21
|
+
|
22
|
+
def flash(value=5)
|
23
|
+
1.upto(value) { web_element.flash }
|
24
|
+
web_element.exists?
|
25
|
+
end
|
26
|
+
|
27
|
+
def tag_name
|
28
|
+
web_element.tag_name
|
29
|
+
end
|
30
|
+
|
31
|
+
def html
|
32
|
+
web_element.html
|
33
|
+
end
|
34
|
+
|
35
|
+
def attribute(name)
|
36
|
+
web_element.attribute_value(name)
|
37
|
+
end
|
38
|
+
|
39
|
+
def fire_event(event)
|
40
|
+
web_element.fire_event(event)
|
41
|
+
end
|
42
|
+
|
43
|
+
def value
|
44
|
+
web_element.value
|
45
|
+
end
|
46
|
+
|
47
|
+
def id
|
48
|
+
web_element.id
|
49
|
+
end
|
50
|
+
|
51
|
+
def send_keys(*args)
|
52
|
+
web_element.send_keys(*args)
|
53
|
+
end
|
54
|
+
|
55
|
+
def scroll_into_view
|
56
|
+
web_element.wd.location_once_scrolled_into_view
|
57
|
+
end
|
58
|
+
|
59
|
+
def focus
|
60
|
+
web_element.focus
|
61
|
+
end
|
62
|
+
|
63
|
+
def hover
|
64
|
+
web_element.hover
|
65
|
+
end
|
66
|
+
|
67
|
+
def when_present(timeout=::Fluent.element_level_wait)
|
68
|
+
web_element.wait_until_present(timeout)
|
69
|
+
self
|
70
|
+
end
|
71
|
+
|
72
|
+
def when_not_present(timeout=::Fluent.element_level_wait)
|
73
|
+
web_element.wait_while_present(timeout)
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
def when_visible(timeout=::Fluent.element_level_wait)
|
78
|
+
Object::Watir::Wait.until(timeout, "Object not visible within #{timeout} seconds.") do
|
79
|
+
visible?
|
80
|
+
end
|
81
|
+
self
|
82
|
+
end
|
83
|
+
|
84
|
+
def when_not_visible(timeout=::Fluent.element_level_wait)
|
85
|
+
Object::Watir::Wait.while(timeout, "Object still visible after #{timeout} seconds.") do
|
86
|
+
visible?
|
87
|
+
end
|
88
|
+
self
|
89
|
+
end
|
90
|
+
|
91
|
+
def wait_until(timeout=::Fluent.element_level_wait, message=nil, &block)
|
92
|
+
Object::Watir::Wait.until(timeout, message, &block)
|
93
|
+
end
|
94
|
+
|
95
|
+
alias_method :when_actionable, :when_present
|
96
|
+
alias_method :when_not_actionable, :when_not_present
|
18
97
|
end
|
19
98
|
end
|
20
99
|
end
|