fluent 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.travis.yml +14 -0
- data/Gemfile +5 -0
- data/HISTORY.md +19 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +13 -0
- data/fluent.gemspec +32 -0
- data/lib/fluent.rb +82 -0
- data/lib/fluent/errors.rb +8 -0
- data/lib/fluent/generators.rb +155 -0
- data/lib/fluent/logger.rb +5 -0
- data/lib/fluent/platform_watir.rb +18 -0
- data/lib/fluent/platform_watir/platform_object.rb +112 -0
- data/lib/fluent/platform_watir/platform_web_elements/select_list.rb +30 -0
- data/lib/fluent/platform_watir/platform_web_elements/web_element.rb +21 -0
- data/lib/fluent/platforms.rb +31 -0
- data/lib/fluent/version.rb +3 -0
- data/lib/fluent/web_elements/button.rb +16 -0
- data/lib/fluent/web_elements/checkbox.rb +16 -0
- data/lib/fluent/web_elements/link.rb +16 -0
- data/lib/fluent/web_elements/option.rb +16 -0
- data/lib/fluent/web_elements/paragraph.rb +16 -0
- data/lib/fluent/web_elements/radio.rb +16 -0
- data/lib/fluent/web_elements/select_list.rb +20 -0
- data/lib/fluent/web_elements/text_field.rb +16 -0
- data/lib/fluent/web_elements/web_element.rb +33 -0
- data/spec/fluent_spec.rb +9 -0
- data/spec/generators/button_generators_spec.rb +77 -0
- data/spec/generators/checkbox_generators_spec.rb +88 -0
- data/spec/generators/link_generators_spec.rb +64 -0
- data/spec/generators/paragraph_generators_spec.rb +65 -0
- data/spec/generators/radio_generators_spec.rb +85 -0
- data/spec/generators/select_list_generators_spec.rb +120 -0
- data/spec/generators/text_field_generators_spec.rb +81 -0
- data/spec/generators_spec.rb +42 -0
- data/spec/mock_app.rb +14 -0
- data/spec/platform_object_spec.rb +23 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/web_element_spec.rb +23 -0
- data/spec/web_element_watir_spec.rb +32 -0
- metadata +183 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
module Fluent
|
2
|
+
module Platforms
|
3
|
+
module WatirWebDriver
|
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.goto(url)
|
16
|
+
end
|
17
|
+
|
18
|
+
## Generator Actions ##
|
19
|
+
|
20
|
+
def link(locator)
|
21
|
+
reference_web_element('link(locator)', WebElements::Link, locator)
|
22
|
+
end
|
23
|
+
|
24
|
+
def link_click(locator)
|
25
|
+
browser.instance_eval('link(locator).click')
|
26
|
+
end
|
27
|
+
|
28
|
+
def button(locator)
|
29
|
+
reference_web_element('button(locator)', WebElements::Button, locator)
|
30
|
+
end
|
31
|
+
|
32
|
+
def button_click(locator)
|
33
|
+
browser.instance_eval('button(locator).click')
|
34
|
+
end
|
35
|
+
|
36
|
+
def text_field(locator)
|
37
|
+
reference_web_element('text_field(locator)', WebElements::TextField, locator)
|
38
|
+
end
|
39
|
+
|
40
|
+
def text_field_set(locator, value)
|
41
|
+
browser.instance_eval('text_field(locator).set(value)')
|
42
|
+
end
|
43
|
+
|
44
|
+
def text_field_get(locator)
|
45
|
+
browser.instance_eval('text_field(locator).value')
|
46
|
+
end
|
47
|
+
|
48
|
+
def checkbox(locator)
|
49
|
+
reference_web_element('checkbox(locator)', WebElements::CheckBox, locator)
|
50
|
+
end
|
51
|
+
|
52
|
+
def checkbox_check_state(locator)
|
53
|
+
browser.instance_eval('checkbox(locator).set?')
|
54
|
+
end
|
55
|
+
|
56
|
+
def checkbox_check(locator)
|
57
|
+
browser.instance_eval('checkbox(locator).set')
|
58
|
+
end
|
59
|
+
|
60
|
+
def checkbox_uncheck(locator)
|
61
|
+
browser.instance_eval('checkbox(locator).clear')
|
62
|
+
end
|
63
|
+
|
64
|
+
def select_list(locator)
|
65
|
+
reference_web_element('select_list(locator)', WebElements::SelectList, locator)
|
66
|
+
end
|
67
|
+
|
68
|
+
def select_list_get_selected(locator)
|
69
|
+
browser.instance_eval('select_list(locator).selected_options[0].text')
|
70
|
+
end
|
71
|
+
|
72
|
+
def select_list_set(locator, value)
|
73
|
+
browser.instance_eval('select_list(locator).select(value)')
|
74
|
+
end
|
75
|
+
|
76
|
+
def select_list_get_value(locator)
|
77
|
+
browser.instance_eval('select_list(locator).value')
|
78
|
+
end
|
79
|
+
|
80
|
+
def radio(locator)
|
81
|
+
reference_web_element('radio(locator)', WebElements::Radio, locator)
|
82
|
+
end
|
83
|
+
|
84
|
+
def radio_select(locator)
|
85
|
+
browser.instance_eval('radio(locator).set')
|
86
|
+
end
|
87
|
+
|
88
|
+
def radio_check_state(locator)
|
89
|
+
browser.instance_eval('radio(locator).set?')
|
90
|
+
end
|
91
|
+
|
92
|
+
def paragraph(locator)
|
93
|
+
reference_web_element('p(locator)', WebElements::Paragraph, locator)
|
94
|
+
end
|
95
|
+
|
96
|
+
def paragraph_text(locator)
|
97
|
+
browser.instance_eval('p(locator).text')
|
98
|
+
end
|
99
|
+
|
100
|
+
def reference_web_element(action, object, locator)
|
101
|
+
element_object = browser.instance_eval(action)
|
102
|
+
object.new(element_object, :platform => :watir_webdriver)
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
require 'fluent/web_elements/web_element'
|
111
|
+
file_list = Dir["#{File.dirname(__FILE__)}/../web_elements/**/*.rb"].reject { |file| file =~ /web_element.rb/ }
|
112
|
+
file_list.each { |file| require file }
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fluent
|
2
|
+
module Platforms
|
3
|
+
module WatirWebDriver
|
4
|
+
module SelectList
|
5
|
+
|
6
|
+
def [](index)
|
7
|
+
::Fluent::WebElements::Option.new(options[index], :platform => :watir_webdriver)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Provides an array of Option objects that are contained within
|
11
|
+
# a select list object.
|
12
|
+
#
|
13
|
+
# @return [Array] Fluent::WebElements::Option objects
|
14
|
+
def options
|
15
|
+
elements = []
|
16
|
+
options = web_element.wd.find_elements(:xpath, option_xpath)
|
17
|
+
options.each do |option|
|
18
|
+
elements << ::Fluent::WebElements::Option.new(option, :platform => :watir_webdriver)
|
19
|
+
end
|
20
|
+
elements
|
21
|
+
end
|
22
|
+
|
23
|
+
def option_xpath
|
24
|
+
'.//child::option'
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fluent
|
2
|
+
module Platforms
|
3
|
+
module WatirWebDriver
|
4
|
+
module WebElement
|
5
|
+
|
6
|
+
def text
|
7
|
+
web_element.text
|
8
|
+
end
|
9
|
+
|
10
|
+
def exists?
|
11
|
+
web_element.exists?
|
12
|
+
end
|
13
|
+
|
14
|
+
def visible?
|
15
|
+
web_element.present?
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Fluent
|
2
|
+
module Platforms
|
3
|
+
|
4
|
+
@drivers = {}
|
5
|
+
|
6
|
+
def self.register(driver, platform)
|
7
|
+
@drivers[driver] = platform
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.list
|
11
|
+
@drivers
|
12
|
+
end
|
13
|
+
|
14
|
+
# This module determines what execution platform Fluent will use. The
|
15
|
+
# decision is based on the browser that has been established for the
|
16
|
+
# execution profile.
|
17
|
+
#
|
18
|
+
# @param browser [Object] the browser to establish the platform for
|
19
|
+
# @return [Object] a platform object to execute tests against
|
20
|
+
def get_platform_for(browser)
|
21
|
+
Fluent::Platforms.list.each_value do |driver|
|
22
|
+
return driver.create_platform_object_for(browser) if driver.works_with?(browser)
|
23
|
+
end
|
24
|
+
msg = "Unable to create a platform object for #{browser}."
|
25
|
+
raise Fluent::Errors::UnableToCreatePlatform, msg
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
require 'fluent/platform_watir'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class Button < WebElement
|
4
|
+
|
5
|
+
def initialize(web_element, platform)
|
6
|
+
@web_element = web_element
|
7
|
+
include_platform_specifics_for platform
|
8
|
+
end
|
9
|
+
|
10
|
+
def include_platform_specifics_for(platform)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class CheckBox < WebElement
|
4
|
+
|
5
|
+
def initialize(web_element, platform)
|
6
|
+
@web_element = web_element
|
7
|
+
include_platform_specifics_for platform
|
8
|
+
end
|
9
|
+
|
10
|
+
def include_platform_specifics_for(platform)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class Link < WebElement
|
4
|
+
|
5
|
+
def initialize(web_element, platform)
|
6
|
+
@web_element = web_element
|
7
|
+
include_platform_specifics_for platform
|
8
|
+
end
|
9
|
+
|
10
|
+
def include_platform_specifics_for(platform)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class Option < WebElement
|
4
|
+
|
5
|
+
def initialize(web_element, platform)
|
6
|
+
@web_element = web_element
|
7
|
+
include_platform_specifics_for platform
|
8
|
+
end
|
9
|
+
|
10
|
+
def include_platform_specifics_for(platform)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class Paragraph < WebElement
|
4
|
+
|
5
|
+
def initialize(web_element, platform)
|
6
|
+
@web_element = web_element
|
7
|
+
include_platform_specifics_for platform
|
8
|
+
end
|
9
|
+
|
10
|
+
def include_platform_specifics_for(platform)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class Radio < WebElement
|
4
|
+
|
5
|
+
def initialize(web_element, platform)
|
6
|
+
@web_element = web_element
|
7
|
+
include_platform_specifics_for platform
|
8
|
+
end
|
9
|
+
|
10
|
+
def include_platform_specifics_for(platform)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class SelectList < WebElement
|
4
|
+
|
5
|
+
def initialize(web_element, platform)
|
6
|
+
@web_element = web_element
|
7
|
+
include_platform_specifics_for platform
|
8
|
+
end
|
9
|
+
|
10
|
+
def include_platform_specifics_for(platform)
|
11
|
+
super
|
12
|
+
if platform[:platform] == :watir_webdriver
|
13
|
+
require 'fluent/platform_watir/platform_web_elements/select_list'
|
14
|
+
self.class.send :include, Fluent::Platforms::WatirWebDriver::SelectList
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class TextField < WebElement
|
4
|
+
|
5
|
+
def initialize(web_element, platform)
|
6
|
+
@web_element = web_element
|
7
|
+
include_platform_specifics_for platform
|
8
|
+
end
|
9
|
+
|
10
|
+
def include_platform_specifics_for(platform)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class WebElement
|
4
|
+
|
5
|
+
attr_reader :web_element
|
6
|
+
|
7
|
+
def initialize(web_element, platform)
|
8
|
+
@web_element = web_element
|
9
|
+
include_platform_specifics_for platform
|
10
|
+
end
|
11
|
+
|
12
|
+
def click
|
13
|
+
web_element.click
|
14
|
+
end
|
15
|
+
|
16
|
+
def enabled?
|
17
|
+
web_element.enabled?
|
18
|
+
end
|
19
|
+
|
20
|
+
def disabled?
|
21
|
+
not enabled?
|
22
|
+
end
|
23
|
+
|
24
|
+
def include_platform_specifics_for(platform)
|
25
|
+
if platform[:platform] == :watir_webdriver
|
26
|
+
require 'fluent/platform_watir/platform_web_elements/web_element'
|
27
|
+
self.class.send :include, ::Fluent::Platforms::WatirWebDriver::WebElement
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/fluent_spec.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
class ButtonGenerators
|
4
|
+
include Fluent
|
5
|
+
|
6
|
+
button :submit, id: 'submit'
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Fluent::Generators do
|
10
|
+
let(:watir_browser) { mock_browser_for_watir }
|
11
|
+
let(:watir_definition) { ButtonGenerators.new(watir_browser) }
|
12
|
+
|
13
|
+
describe 'button generators' do
|
14
|
+
context 'when declared on a page definition' do
|
15
|
+
it 'should generate methods for referencing the button' do
|
16
|
+
watir_definition.should respond_to(:submit_object)
|
17
|
+
watir_definition.should respond_to(:submit_element)
|
18
|
+
watir_definition.should respond_to(:submit_button)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should generate methods for interacting with the button' do
|
22
|
+
watir_definition.should respond_to(:submit)
|
23
|
+
watir_definition.should respond_to(:submit_exists?)
|
24
|
+
watir_definition.should respond_to(:submit_visible?)
|
25
|
+
watir_definition.should respond_to(:submit_enabled?)
|
26
|
+
watir_definition.should respond_to(:submit?)
|
27
|
+
watir_definition.should respond_to(:submit_?)
|
28
|
+
watir_definition.should respond_to(:submit!)
|
29
|
+
watir_definition.should respond_to(:submit_button_exists?)
|
30
|
+
watir_definition.should respond_to(:submit_button_visible?)
|
31
|
+
watir_definition.should respond_to(:submit_button_enabled?)
|
32
|
+
watir_definition.should respond_to(:submit_button?)
|
33
|
+
watir_definition.should respond_to(:submit_button_?)
|
34
|
+
watir_definition.should respond_to(:submit_button!)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when used by the watir platform' do
|
39
|
+
it 'should locate the button' do
|
40
|
+
watir_browser.should_receive(:button).and_return(watir_browser)
|
41
|
+
web_element = watir_definition.submit_object
|
42
|
+
web_element.should_not be_nil
|
43
|
+
web_element.should be_instance_of Fluent::WebElements::Button
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should click the button' do
|
47
|
+
watir_browser.should_receive(:button).and_return(watir_browser)
|
48
|
+
watir_browser.should_receive(:click)
|
49
|
+
watir_definition.submit
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should determine if a button exists' do
|
53
|
+
watir_browser.should_receive(:button).exactly(3).times.and_return(watir_browser)
|
54
|
+
watir_browser.should_receive(:exists?).exactly(3).times.and_return(watir_browser)
|
55
|
+
watir_definition.submit?.should be_true
|
56
|
+
watir_definition.submit_exists?.should be_true
|
57
|
+
watir_definition.submit_button_exists?.should be_true
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should determine if a button is visible' do
|
61
|
+
watir_browser.should_receive(:button).exactly(3).times.and_return(watir_browser)
|
62
|
+
watir_browser.should_receive(:present?).exactly(3).times.and_return(watir_browser)
|
63
|
+
watir_definition.submit_?.should be_true
|
64
|
+
watir_definition.submit_visible?.should be_true
|
65
|
+
watir_definition.submit_button_visible?.should be_true
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should determine if a button is enabled' do
|
69
|
+
watir_browser.should_receive(:button).exactly(3).times.and_return(watir_browser)
|
70
|
+
watir_browser.should_receive(:enabled?).exactly(3).times.and_return(watir_browser)
|
71
|
+
watir_definition.submit!.should be_true
|
72
|
+
watir_definition.submit_enabled?.should be_true
|
73
|
+
watir_definition.submit_button_enabled?.should be_true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|