fluent 0.2.0 → 0.3.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 +9 -0
- data/lib/fluent/errors.rb +1 -0
- data/lib/fluent/factory.rb +9 -0
- data/lib/fluent/generators.rb +65 -4
- data/lib/fluent/platform_watir/platform_object.rb +92 -3
- data/lib/fluent/platform_watir/platform_web_elements/ordered_list.rb +26 -0
- data/lib/fluent/platform_watir/platform_web_elements/table.rb +25 -0
- data/lib/fluent/platform_watir/platform_web_elements/table_row.rb +27 -0
- data/lib/fluent/platform_watir/platform_web_elements/text_area.rb +21 -0
- data/lib/fluent/platform_watir/platform_web_elements/text_field.rb +4 -0
- data/lib/fluent/platform_watir/platform_web_elements/unordered_list.rb +26 -0
- data/lib/fluent/platform_watir/platform_web_elements/web_element.rb +7 -0
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/web_elements.rb +20 -0
- data/lib/fluent/web_elements/button.rb +6 -1
- data/lib/fluent/web_elements/cell.rb +3 -0
- data/lib/fluent/web_elements/checkbox.rb +3 -1
- data/lib/fluent/web_elements/div.rb +2 -0
- data/lib/fluent/web_elements/form.rb +18 -0
- data/lib/fluent/web_elements/heading.rb +23 -0
- data/lib/fluent/web_elements/hidden.rb +18 -0
- data/lib/fluent/web_elements/image.rb +18 -0
- data/lib/fluent/web_elements/label.rb +18 -0
- data/lib/fluent/web_elements/link.rb +2 -0
- data/lib/fluent/web_elements/list_item.rb +2 -0
- data/lib/fluent/web_elements/option.rb +2 -0
- data/lib/fluent/web_elements/ordered_list.rb +19 -1
- data/lib/fluent/web_elements/paragraph.rb +2 -0
- data/lib/fluent/web_elements/radio.rb +3 -1
- data/lib/fluent/web_elements/select_list.rb +2 -0
- data/lib/fluent/web_elements/span.rb +3 -0
- data/lib/fluent/web_elements/table.rb +32 -0
- data/lib/fluent/web_elements/table_row.rb +38 -0
- data/lib/fluent/web_elements/text_area.rb +6 -0
- data/lib/fluent/web_elements/text_field.rb +3 -0
- data/lib/fluent/web_elements/unordered_list.rb +20 -1
- data/spec/factory_spec.rb +7 -0
- data/spec/generators/form_generators_spec.rb +42 -0
- data/spec/generators/heading_generators_spec.rb +87 -0
- data/spec/generators/hidden_generators_spec.rb +49 -0
- data/spec/generators/image_generators_spec.rb +42 -0
- data/spec/generators/label_generators_spec.rb +49 -0
- data/spec/generators/text_area_generators_spec.rb +3 -3
- data/spec/generators_spec.rb +5 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/web_element_watir_spec.rb +6 -0
- data/spec/web_elements/button_spec.rb +21 -0
- data/spec/web_elements/cell_spec.rb +13 -0
- data/spec/web_elements/checkbox_spec.rb +4 -0
- data/spec/web_elements/div_spec.rb +9 -0
- data/spec/web_elements/form_spec.rb +9 -0
- data/spec/web_elements/heading_spec.rb +28 -0
- data/spec/web_elements/hidden_spec.rb +9 -0
- data/spec/web_elements/image_spec.rb +9 -0
- data/spec/web_elements/label_spec.rb +9 -0
- data/spec/web_elements/link_spec.rb +9 -0
- data/spec/web_elements/list_item_spec.rb +9 -0
- data/spec/web_elements/option_spec.rb +9 -0
- data/spec/web_elements/ordered_list_spec.rb +42 -0
- data/spec/web_elements/paragraph_spec.rb +9 -0
- data/spec/web_elements/radio_spec.rb +4 -0
- data/spec/web_elements/select_list_spec.rb +4 -0
- data/spec/web_elements/span_spec.rb +9 -0
- data/spec/web_elements/table_row_spec.rb +47 -0
- data/spec/web_elements/table_spec.rb +54 -0
- data/spec/web_elements/text_area_spec.rb +27 -0
- data/spec/web_elements/text_field_spec.rb +13 -0
- data/spec/web_elements/unordered_list_spec.rb +42 -0
- metadata +61 -2
@@ -91,6 +91,13 @@ module Fluent
|
|
91
91
|
def wait_until(timeout=::Fluent.element_level_wait, message=nil, &block)
|
92
92
|
Object::Watir::Wait.until(timeout, message, &block)
|
93
93
|
end
|
94
|
+
|
95
|
+
def parent
|
96
|
+
parent = web_element.parent
|
97
|
+
type = web_element.type if parent.tag_name.to_sym == :input
|
98
|
+
object_class = ::Fluent::WebElements.get_class_for(parent.tag_name, type)
|
99
|
+
object_class.new(parent, :platform => :watir_webdriver)
|
100
|
+
end
|
94
101
|
|
95
102
|
alias_method :when_actionable, :when_present
|
96
103
|
alias_method :when_not_actionable, :when_not_present
|
data/lib/fluent/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def class_for_tag
|
6
|
+
@class_for_tag ||= {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def class_for_type
|
10
|
+
@class_for_type ||= {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_class_for(tag, type=nil)
|
14
|
+
return class_for_type[type.to_sym] if type
|
15
|
+
class_for_tag[tag.to_sym] || ::Fluent::WebElements::WebElement
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -10,7 +10,12 @@ module Fluent
|
|
10
10
|
def include_platform_specifics_for(platform)
|
11
11
|
super
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
end
|
15
|
+
|
16
|
+
::Fluent::WebElements.class_for_type[:submit] = ::Fluent::WebElements::Button
|
17
|
+
::Fluent::WebElements.class_for_type[:button] = ::Fluent::WebElements::Button
|
18
|
+
::Fluent::WebElements.class_for_type[:image] = ::Fluent::WebElements::Button
|
19
|
+
::Fluent::WebElements.class_for_type[:reset] = ::Fluent::WebElements::Button
|
15
20
|
end
|
16
21
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class Form < 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
|
+
|
16
|
+
::Fluent::WebElements.class_for_tag[:form] = ::Fluent::WebElements::Form
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class Heading < 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
|
+
|
16
|
+
::Fluent::WebElements.class_for_tag[:h1] = ::Fluent::WebElements::Heading
|
17
|
+
::Fluent::WebElements.class_for_tag[:h2] = ::Fluent::WebElements::Heading
|
18
|
+
::Fluent::WebElements.class_for_tag[:h3] = ::Fluent::WebElements::Heading
|
19
|
+
::Fluent::WebElements.class_for_tag[:h4] = ::Fluent::WebElements::Heading
|
20
|
+
::Fluent::WebElements.class_for_tag[:h5] = ::Fluent::WebElements::Heading
|
21
|
+
::Fluent::WebElements.class_for_tag[:h6] = ::Fluent::WebElements::Heading
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class Hidden < 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
|
+
|
16
|
+
::Fluent::WebElements.class_for_tag[:hidden] = ::Fluent::WebElements::Hidden
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class Image < 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
|
+
|
16
|
+
::Fluent::WebElements.class_for_tag[:img] = ::Fluent::WebElements::Image
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class Label < 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
|
+
|
16
|
+
::Fluent::WebElements.class_for_tag[:label] = ::Fluent::WebElements::Label
|
17
|
+
end
|
18
|
+
end
|
@@ -1,16 +1,34 @@
|
|
1
1
|
module Fluent
|
2
2
|
module WebElements
|
3
3
|
class OrderedList < WebElement
|
4
|
-
|
4
|
+
include Enumerable
|
5
|
+
|
5
6
|
def initialize(web_element, platform)
|
6
7
|
@web_element = web_element
|
7
8
|
include_platform_specifics_for platform
|
8
9
|
end
|
10
|
+
|
11
|
+
# @return [Fluent::WebElements::ListItem]
|
12
|
+
def each
|
13
|
+
for index in 1..self.items do
|
14
|
+
yield self[index - 1]
|
15
|
+
end
|
16
|
+
end
|
9
17
|
|
18
|
+
def list_item_xpath
|
19
|
+
'.//child::li'
|
20
|
+
end
|
21
|
+
|
10
22
|
def include_platform_specifics_for(platform)
|
11
23
|
super
|
24
|
+
if platform[:platform] == :watir_webdriver
|
25
|
+
require 'fluent/platform_watir/platform_web_elements/ordered_list'
|
26
|
+
self.class.send :include, Fluent::Platforms::WatirWebDriver::OrderedList
|
27
|
+
end
|
12
28
|
end
|
13
29
|
|
14
30
|
end
|
31
|
+
|
32
|
+
::Fluent::WebElements.class_for_tag[:ol] = ::Fluent::WebElements::OrderedList
|
15
33
|
end
|
16
34
|
end
|
@@ -1,16 +1,48 @@
|
|
1
1
|
module Fluent
|
2
2
|
module WebElements
|
3
3
|
class Table < WebElement
|
4
|
+
include Enumerable
|
4
5
|
|
5
6
|
def initialize(web_element, platform)
|
6
7
|
@web_element = web_element
|
7
8
|
include_platform_specifics_for platform
|
8
9
|
end
|
9
10
|
|
11
|
+
# @return [Fluent::WebElements::TableRow]
|
12
|
+
def each
|
13
|
+
for index in 1..self.rows do
|
14
|
+
yield self[index - 1]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Fluent::WebElements::TableRow]
|
19
|
+
def first_row
|
20
|
+
self[0]
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Fluent::WebElements::TableRow]
|
24
|
+
def last_row
|
25
|
+
self[-1]
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize_row(element, platform)
|
29
|
+
::Fluent::WebElements::TableRow.new(element, platform)
|
30
|
+
end
|
31
|
+
|
32
|
+
def row_xpath
|
33
|
+
'.//child::tr'
|
34
|
+
end
|
35
|
+
|
10
36
|
def include_platform_specifics_for(platform)
|
11
37
|
super
|
38
|
+
if platform[:platform] == :watir_webdriver
|
39
|
+
require 'fluent/platform_watir/platform_web_elements/table'
|
40
|
+
self.class.send :include, Fluent::Platforms::WatirWebDriver::Table
|
41
|
+
end
|
12
42
|
end
|
13
43
|
|
14
44
|
end
|
45
|
+
|
46
|
+
::Fluent::WebElements.class_for_tag[:table] = ::Fluent::WebElements::Table
|
15
47
|
end
|
16
48
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WebElements
|
3
|
+
class TableRow < WebElement
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
def initialize(web_element, platform)
|
7
|
+
@web_element = web_element
|
8
|
+
include_platform_specifics_for platform
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Fluent::WebElements::Cell]
|
12
|
+
def each
|
13
|
+
for index in 1..self.columns do
|
14
|
+
yield self[index - 1]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize_cell(row_element, platform)
|
19
|
+
::Fluent::WebElements::Cell.new(row_element, platform)
|
20
|
+
end
|
21
|
+
|
22
|
+
def cell_xpath
|
23
|
+
'.//child::td|th'
|
24
|
+
end
|
25
|
+
|
26
|
+
def include_platform_specifics_for(platform)
|
27
|
+
super
|
28
|
+
if platform[:platform] == :watir_webdriver
|
29
|
+
require 'fluent/platform_watir/platform_web_elements/table_row'
|
30
|
+
self.class.send :include, Fluent::Platforms::WatirWebDriver::TableRow
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
::Fluent::WebElements.class_for_tag[:tr] = ::Fluent::WebElements::TableRow
|
37
|
+
end
|
38
|
+
end
|
@@ -9,8 +9,14 @@ module Fluent
|
|
9
9
|
|
10
10
|
def include_platform_specifics_for(platform)
|
11
11
|
super
|
12
|
+
if platform[:platform] == :watir_webdriver
|
13
|
+
require 'fluent/platform_watir/platform_web_elements/text_area'
|
14
|
+
self.class.send :include, Fluent::Platforms::WatirWebDriver::TextArea
|
15
|
+
end
|
12
16
|
end
|
13
17
|
|
14
18
|
end
|
19
|
+
|
20
|
+
::Fluent::WebElements.class_for_tag[:textarea] = ::Fluent::WebElements::TextArea
|
15
21
|
end
|
16
22
|
end
|
@@ -1,16 +1,35 @@
|
|
1
1
|
module Fluent
|
2
2
|
module WebElements
|
3
3
|
class UnorderedList < WebElement
|
4
|
-
|
4
|
+
include Enumerable
|
5
|
+
|
5
6
|
def initialize(web_element, platform)
|
6
7
|
@web_element = web_element
|
7
8
|
include_platform_specifics_for platform
|
8
9
|
end
|
9
10
|
|
11
|
+
# @return [Fluent::WebElements::ListItem]
|
12
|
+
def each
|
13
|
+
for index in 1..self.items do
|
14
|
+
yield self[index - 1]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def list_item_xpath
|
19
|
+
'.//child::li'
|
20
|
+
end
|
21
|
+
|
10
22
|
def include_platform_specifics_for(platform)
|
11
23
|
super
|
24
|
+
if platform[:platform] == :watir_webdriver
|
25
|
+
require 'fluent/platform_watir/platform_web_elements/unordered_list'
|
26
|
+
self.class.send :include, Fluent::Platforms::WatirWebDriver::UnorderedList
|
27
|
+
end
|
12
28
|
end
|
13
29
|
|
14
30
|
end
|
31
|
+
|
32
|
+
::Fluent::WebElements.class_for_tag[:ul] = ::Fluent::WebElements::UnorderedList
|
33
|
+
|
15
34
|
end
|
16
35
|
end
|
data/spec/factory_spec.rb
CHANGED
@@ -39,4 +39,11 @@ describe Fluent::Factory do
|
|
39
39
|
current.should === active
|
40
40
|
end
|
41
41
|
|
42
|
+
it 'should create a new definition based on a string' do
|
43
|
+
@factory.browser.should_receive(:goto)
|
44
|
+
@factory.on_view "DefinitionTest" do |page|
|
45
|
+
page.should be_instance_of DefinitionTest
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
42
49
|
end
|