fluent 0.2.0 → 0.3.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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +9 -0
  3. data/lib/fluent/errors.rb +1 -0
  4. data/lib/fluent/factory.rb +9 -0
  5. data/lib/fluent/generators.rb +65 -4
  6. data/lib/fluent/platform_watir/platform_object.rb +92 -3
  7. data/lib/fluent/platform_watir/platform_web_elements/ordered_list.rb +26 -0
  8. data/lib/fluent/platform_watir/platform_web_elements/table.rb +25 -0
  9. data/lib/fluent/platform_watir/platform_web_elements/table_row.rb +27 -0
  10. data/lib/fluent/platform_watir/platform_web_elements/text_area.rb +21 -0
  11. data/lib/fluent/platform_watir/platform_web_elements/text_field.rb +4 -0
  12. data/lib/fluent/platform_watir/platform_web_elements/unordered_list.rb +26 -0
  13. data/lib/fluent/platform_watir/platform_web_elements/web_element.rb +7 -0
  14. data/lib/fluent/version.rb +1 -1
  15. data/lib/fluent/web_elements.rb +20 -0
  16. data/lib/fluent/web_elements/button.rb +6 -1
  17. data/lib/fluent/web_elements/cell.rb +3 -0
  18. data/lib/fluent/web_elements/checkbox.rb +3 -1
  19. data/lib/fluent/web_elements/div.rb +2 -0
  20. data/lib/fluent/web_elements/form.rb +18 -0
  21. data/lib/fluent/web_elements/heading.rb +23 -0
  22. data/lib/fluent/web_elements/hidden.rb +18 -0
  23. data/lib/fluent/web_elements/image.rb +18 -0
  24. data/lib/fluent/web_elements/label.rb +18 -0
  25. data/lib/fluent/web_elements/link.rb +2 -0
  26. data/lib/fluent/web_elements/list_item.rb +2 -0
  27. data/lib/fluent/web_elements/option.rb +2 -0
  28. data/lib/fluent/web_elements/ordered_list.rb +19 -1
  29. data/lib/fluent/web_elements/paragraph.rb +2 -0
  30. data/lib/fluent/web_elements/radio.rb +3 -1
  31. data/lib/fluent/web_elements/select_list.rb +2 -0
  32. data/lib/fluent/web_elements/span.rb +3 -0
  33. data/lib/fluent/web_elements/table.rb +32 -0
  34. data/lib/fluent/web_elements/table_row.rb +38 -0
  35. data/lib/fluent/web_elements/text_area.rb +6 -0
  36. data/lib/fluent/web_elements/text_field.rb +3 -0
  37. data/lib/fluent/web_elements/unordered_list.rb +20 -1
  38. data/spec/factory_spec.rb +7 -0
  39. data/spec/generators/form_generators_spec.rb +42 -0
  40. data/spec/generators/heading_generators_spec.rb +87 -0
  41. data/spec/generators/hidden_generators_spec.rb +49 -0
  42. data/spec/generators/image_generators_spec.rb +42 -0
  43. data/spec/generators/label_generators_spec.rb +49 -0
  44. data/spec/generators/text_area_generators_spec.rb +3 -3
  45. data/spec/generators_spec.rb +5 -0
  46. data/spec/spec_helper.rb +2 -0
  47. data/spec/web_element_watir_spec.rb +6 -0
  48. data/spec/web_elements/button_spec.rb +21 -0
  49. data/spec/web_elements/cell_spec.rb +13 -0
  50. data/spec/web_elements/checkbox_spec.rb +4 -0
  51. data/spec/web_elements/div_spec.rb +9 -0
  52. data/spec/web_elements/form_spec.rb +9 -0
  53. data/spec/web_elements/heading_spec.rb +28 -0
  54. data/spec/web_elements/hidden_spec.rb +9 -0
  55. data/spec/web_elements/image_spec.rb +9 -0
  56. data/spec/web_elements/label_spec.rb +9 -0
  57. data/spec/web_elements/link_spec.rb +9 -0
  58. data/spec/web_elements/list_item_spec.rb +9 -0
  59. data/spec/web_elements/option_spec.rb +9 -0
  60. data/spec/web_elements/ordered_list_spec.rb +42 -0
  61. data/spec/web_elements/paragraph_spec.rb +9 -0
  62. data/spec/web_elements/radio_spec.rb +4 -0
  63. data/spec/web_elements/select_list_spec.rb +4 -0
  64. data/spec/web_elements/span_spec.rb +9 -0
  65. data/spec/web_elements/table_row_spec.rb +47 -0
  66. data/spec/web_elements/table_spec.rb +54 -0
  67. data/spec/web_elements/text_area_spec.rb +27 -0
  68. data/spec/web_elements/text_field_spec.rb +13 -0
  69. data/spec/web_elements/unordered_list_spec.rb +42 -0
  70. 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
@@ -1,3 +1,3 @@
1
1
  module Fluent
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -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
@@ -12,5 +12,8 @@ module Fluent
12
12
  end
13
13
 
14
14
  end
15
+
16
+ ::Fluent::WebElements.class_for_tag[:td] = ::Fluent::WebElements::Cell
17
+ ::Fluent::WebElements.class_for_tag[:th] = ::Fluent::WebElements::Cell
15
18
  end
16
19
  end
@@ -14,7 +14,9 @@ module Fluent
14
14
  self.class.send :include, Fluent::Platforms::WatirWebDriver::CheckBox
15
15
  end
16
16
  end
17
-
17
+
18
18
  end
19
+
20
+ ::Fluent::WebElements.class_for_type[:checkbox] = ::Fluent::WebElements::CheckBox
19
21
  end
20
22
  end
@@ -12,5 +12,7 @@ module Fluent
12
12
  end
13
13
 
14
14
  end
15
+
16
+ ::Fluent::WebElements.class_for_tag[:div] = ::Fluent::WebElements::Div
15
17
  end
16
18
  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
@@ -12,5 +12,7 @@ module Fluent
12
12
  end
13
13
 
14
14
  end
15
+
16
+ ::Fluent::WebElements.class_for_tag[:a] = ::Fluent::WebElements::Link
15
17
  end
16
18
  end
@@ -12,5 +12,7 @@ module Fluent
12
12
  end
13
13
 
14
14
  end
15
+
16
+ ::Fluent::WebElements.class_for_tag[:li] = ::Fluent::WebElements::ListItem
15
17
  end
16
18
  end
@@ -12,5 +12,7 @@ module Fluent
12
12
  end
13
13
 
14
14
  end
15
+
16
+ ::Fluent::WebElements.class_for_tag[:option] = ::Fluent::WebElements::Option
15
17
  end
16
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
@@ -12,5 +12,7 @@ module Fluent
12
12
  end
13
13
 
14
14
  end
15
+
16
+ ::Fluent::WebElements.class_for_tag[:p] = ::Fluent::WebElements::Paragraph
15
17
  end
16
18
  end
@@ -14,7 +14,9 @@ module Fluent
14
14
  self.class.send :include, Fluent::Platforms::WatirWebDriver::Radio
15
15
  end
16
16
  end
17
-
17
+
18
18
  end
19
+
20
+ ::Fluent::WebElements.class_for_type[:radio] = ::Fluent::WebElements::Radio
19
21
  end
20
22
  end
@@ -20,5 +20,7 @@ module Fluent
20
20
  end
21
21
 
22
22
  end
23
+
24
+ ::Fluent::WebElements.class_for_tag[:select] = ::Fluent::WebElements::SelectList
23
25
  end
24
26
  end
@@ -12,5 +12,8 @@ module Fluent
12
12
  end
13
13
 
14
14
  end
15
+
16
+ ::Fluent::WebElements.class_for_tag[:span] = ::Fluent::WebElements::Span
17
+
15
18
  end
16
19
  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
@@ -20,5 +20,8 @@ module Fluent
20
20
  end
21
21
 
22
22
  end
23
+
24
+ ::Fluent::WebElements.class_for_type[:text] = ::Fluent::WebElements::TextField
25
+ ::Fluent::WebElements.class_for_type[:password] = ::Fluent::WebElements::TextField
23
26
  end
24
27
  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
@@ -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