page-object 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. data/.gitignore +1 -0
  2. data/.rvmrc +1 -1
  3. data/ChangeLog +12 -6
  4. data/README.md +1 -1
  5. data/Rakefile +3 -19
  6. data/features/async.feature +8 -8
  7. data/features/button.feature +7 -7
  8. data/features/check_box.feature +8 -8
  9. data/features/div.feature +7 -6
  10. data/features/element_attributes.feature +14 -14
  11. data/features/form.feature +5 -5
  12. data/features/frames.feature +12 -0
  13. data/features/hidden_field.feature +5 -5
  14. data/features/html/frame_1.html +18 -0
  15. data/features/html/frame_2.html +16 -0
  16. data/features/html/frames.html +11 -0
  17. data/features/html/iframes.html +12 -0
  18. data/features/html/static_elements.html +50 -42
  19. data/features/html/success.html +5 -5
  20. data/features/image.feature +11 -11
  21. data/features/link.feature +1 -1
  22. data/features/list_item.feature +5 -5
  23. data/features/ordered_list.feature +6 -6
  24. data/features/page_level_actions.feature +16 -5
  25. data/features/radio_button.feature +12 -12
  26. data/features/select_list.feature +12 -12
  27. data/features/span.feature +5 -5
  28. data/features/step_definitions/accessor_steps.rb +2 -2
  29. data/features/step_definitions/async_steps.rb +1 -1
  30. data/features/step_definitions/element_steps.rb +1 -1
  31. data/features/step_definitions/frames_steps.rb +21 -0
  32. data/features/step_definitions/page_level_actions_steps.rb +24 -2
  33. data/features/step_definitions/page_traversal_steps.rb +0 -1
  34. data/features/support/env.rb +20 -6
  35. data/features/support/page.rb +14 -11
  36. data/features/support/url_helper.rb +4 -0
  37. data/features/table.feature +9 -9
  38. data/features/table_cell.feature +6 -6
  39. data/features/text_area.feature +6 -6
  40. data/features/text_field.feature +7 -7
  41. data/features/unordered_list.feature +6 -6
  42. data/lib/page-object.rb +40 -16
  43. data/lib/page-object/accessors.rb +15 -15
  44. data/lib/page-object/elements.rb +0 -1
  45. data/lib/page-object/elements/button.rb +24 -24
  46. data/lib/page-object/elements/div.rb +8 -3
  47. data/lib/page-object/elements/element.rb +27 -28
  48. data/lib/page-object/elements/form.rb +7 -7
  49. data/lib/page-object/elements/hidden_field.rb +5 -5
  50. data/lib/page-object/elements/image.rb +8 -8
  51. data/lib/page-object/elements/link.rb +9 -9
  52. data/lib/page-object/elements/list_item.rb +1 -1
  53. data/lib/page-object/elements/option.rb +1 -1
  54. data/lib/page-object/elements/ordered_list.rb +13 -13
  55. data/lib/page-object/elements/select_list.rb +6 -6
  56. data/lib/page-object/elements/span.rb +2 -2
  57. data/lib/page-object/elements/table.rb +11 -11
  58. data/lib/page-object/elements/table_row.rb +9 -9
  59. data/lib/page-object/elements/text_area.rb +4 -4
  60. data/lib/page-object/elements/text_field.rb +4 -4
  61. data/lib/page-object/elements/unordered_list.rb +13 -13
  62. data/lib/page-object/loads_platform.rb +24 -0
  63. data/lib/page-object/page_factory.rb +3 -3
  64. data/lib/page-object/platforms.rb +18 -0
  65. data/lib/page-object/platforms/selenium.rb +16 -0
  66. data/lib/page-object/platforms/selenium/button.rb +15 -0
  67. data/lib/page-object/platforms/selenium/element.rb +168 -0
  68. data/lib/page-object/platforms/selenium/form.rb +16 -0
  69. data/lib/page-object/platforms/selenium/image.rb +28 -0
  70. data/lib/page-object/platforms/selenium/link.rb +16 -0
  71. data/lib/page-object/platforms/selenium/ordered_list.rb +33 -0
  72. data/lib/page-object/platforms/selenium/page_object.rb +524 -0
  73. data/lib/page-object/platforms/selenium/select_list.rb +32 -0
  74. data/lib/page-object/platforms/selenium/table.rb +40 -0
  75. data/lib/page-object/platforms/selenium/table_row.rb +32 -0
  76. data/lib/page-object/platforms/selenium/unordered_list.rb +33 -0
  77. data/lib/page-object/platforms/watir.rb +16 -0
  78. data/lib/page-object/platforms/watir/element.rb +154 -0
  79. data/lib/page-object/platforms/watir/form.rb +16 -0
  80. data/lib/page-object/platforms/watir/image.rb +22 -0
  81. data/lib/page-object/platforms/watir/ordered_list.rb +32 -0
  82. data/lib/page-object/{watir_page_object.rb → platforms/watir/page_object.rb} +62 -35
  83. data/lib/page-object/platforms/watir/select_list.rb +33 -0
  84. data/lib/page-object/platforms/watir/table.rb +27 -0
  85. data/lib/page-object/platforms/watir/table_row.rb +24 -0
  86. data/lib/page-object/platforms/watir/unordered_list.rb +33 -0
  87. data/lib/page-object/version.rb +1 -1
  88. data/page-object.gemspec +13 -13
  89. data/spec/page-object/accessors_spec.rb +142 -108
  90. data/spec/page-object/elements/button_spec.rb +33 -33
  91. data/spec/page-object/elements/check_box_spec.rb +1 -1
  92. data/spec/page-object/elements/div_spec.rb +3 -3
  93. data/spec/page-object/elements/element_spec.rb +51 -41
  94. data/spec/page-object/elements/form_spec.rb +3 -3
  95. data/spec/page-object/elements/hidden_field_spec.rb +3 -3
  96. data/spec/page-object/elements/image_spec.rb +7 -7
  97. data/spec/page-object/elements/link_spec.rb +8 -8
  98. data/spec/page-object/elements/list_item_spec.rb +1 -1
  99. data/spec/page-object/elements/ordered_list_spec.rb +9 -9
  100. data/spec/page-object/elements/radio_button_spec.rb +1 -1
  101. data/spec/page-object/elements/select_list_spec.rb +2 -2
  102. data/spec/page-object/elements/span_spec.rb +1 -1
  103. data/spec/page-object/elements/table_row_spec.rb +6 -6
  104. data/spec/page-object/elements/table_spec.rb +9 -9
  105. data/spec/page-object/elements/text_area_spec.rb +3 -3
  106. data/spec/page-object/elements/text_field_spec.rb +3 -3
  107. data/spec/page-object/elements/unordered_list_spec.rb +10 -10
  108. data/spec/page-object/loads_platform_spec.rb +38 -0
  109. data/spec/page-object/page-object_spec.rb +70 -10
  110. data/spec/page-object/page_factory_spec.rb +3 -3
  111. data/spec/page-object/{selenium_page_object_spec.rb → platforms/selenium/selenium_page_object_spec.rb} +10 -3
  112. data/spec/page-object/platforms/selenium_spec.rb +26 -0
  113. data/spec/page-object/platforms/watir_spec.rb +27 -0
  114. data/spec/spec_helper.rb +18 -5
  115. metadata +48 -26
  116. data/lib/page-object/platforms/selenium_button.rb +0 -13
  117. data/lib/page-object/platforms/selenium_element.rb +0 -142
  118. data/lib/page-object/platforms/selenium_form.rb +0 -14
  119. data/lib/page-object/platforms/selenium_image.rb +0 -26
  120. data/lib/page-object/platforms/selenium_link.rb +0 -13
  121. data/lib/page-object/platforms/selenium_ordered_list.rb +0 -31
  122. data/lib/page-object/platforms/selenium_select_list.rb +0 -29
  123. data/lib/page-object/platforms/selenium_table.rb +0 -38
  124. data/lib/page-object/platforms/selenium_table_row.rb +0 -29
  125. data/lib/page-object/platforms/selenium_unordered_list.rb +0 -31
  126. data/lib/page-object/platforms/watir_element.rb +0 -136
  127. data/lib/page-object/platforms/watir_form.rb +0 -14
  128. data/lib/page-object/platforms/watir_image.rb +0 -20
  129. data/lib/page-object/platforms/watir_ordered_list.rb +0 -30
  130. data/lib/page-object/platforms/watir_select_list.rb +0 -30
  131. data/lib/page-object/platforms/watir_table.rb +0 -24
  132. data/lib/page-object/platforms/watir_table_row.rb +0 -22
  133. data/lib/page-object/platforms/watir_unordered_list.rb +0 -31
  134. data/lib/page-object/selenium_page_object.rb +0 -486
@@ -1,14 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module SeleniumForm
4
-
5
- #
6
- # Submit the form.
7
- #
8
- def submit
9
- @element.submit
10
- end
11
-
12
- end
13
- end
14
- end
@@ -1,26 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module SeleniumImage
4
-
5
- #
6
- # Return the width of the image.
7
- #
8
- def width
9
- dimension.width
10
- end
11
-
12
- #
13
- # Return the height of the image
14
- #
15
- def height
16
- dimension.height
17
- end
18
-
19
- private
20
-
21
- def dimension
22
- @element.size
23
- end
24
- end
25
- end
26
- end
@@ -1,13 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module SeleniumLink
4
- #
5
- # Override PageObject::PLatforms::SeleniumElement#value because
6
- # #value is not available on links in Selenium.
7
- #
8
- def value
9
- raise "value not available on link element with Selenium"
10
- end
11
- end
12
- end
13
- end
@@ -1,31 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module SeleniumOrderedList
4
-
5
- #
6
- # Return the PageObject::Elements::ListItem for the index provided. Index
7
- # is zero based.
8
- #
9
- # @return [PageObject::Elements::ListItem]
10
- #
11
- def [](idx)
12
- eles = list_items
13
- PageObject::Elements::ListItem.new(eles[idx], :platform => :selenium)
14
- end
15
-
16
- #
17
- # Return the number of items contained in the ordered list
18
- #
19
- def items
20
- list_items.size
21
- end
22
-
23
- private
24
-
25
- def list_items
26
- element.find_elements(:xpath, child_xpath)
27
- end
28
-
29
- end
30
- end
31
- end
@@ -1,29 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module SeleniumSelectList
4
-
5
- #
6
- # Return the PageObject::Elements::Option for the index provided. Index
7
- # is zero based.
8
- #
9
- # @return [PageObject::Elements::Option]
10
- #
11
- def [](idx)
12
- options[idx]
13
- end
14
-
15
- #
16
- # Return an array of Options contained in the select lit.
17
- #
18
- # @return [array of PageObject::Elements::Option]
19
- def options
20
- options = @element.find_elements(:xpath, child_xpath)
21
- elements = []
22
- options.each do |opt|
23
- elements << PageObject::Elements::Option.new(opt, :platform => :selenium)
24
- end
25
- elements
26
- end
27
- end
28
- end
29
- end
@@ -1,38 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module SeleniumTable
4
-
5
- #
6
- # Return the PageObject::Elements::TableRow for the index provided. Index
7
- # is zero based.
8
- #
9
- # @return [PageObject::Elements::TableRow]
10
- #
11
- def [](idx)
12
- eles = table_rows
13
- PageObject::Elements::TableRow.new(eles[idx], :platform => :selenium)
14
- end
15
-
16
- #
17
- # Returns the number of rows in the table.
18
- #
19
- def rows
20
- table_rows.size
21
- end
22
-
23
- #
24
- # override PageObject::Platforms::SeleniumElement because exists? is not
25
- # available on a table element in Selenium.
26
- #
27
- def exists?
28
- raise "exists? not available on table element"
29
- end
30
-
31
- private
32
-
33
- def table_rows
34
- @element.find_elements(:xpath, child_xpath)
35
- end
36
- end
37
- end
38
- end
@@ -1,29 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module SeleniumTableRow
4
-
5
- #
6
- # Return the PageObject::Elements::TableCell for the index provided. Index
7
- # is zero based.
8
- #
9
- def [](idx)
10
- els = table_cells
11
- PageObject::Elements::TableCell.new(els[idx], :platform => :selenium)
12
- end
13
-
14
- #
15
- # Returns the number of columns in the table.
16
- #
17
- def columns
18
- table_cells.size
19
- end
20
-
21
- private
22
-
23
- def table_cells
24
- element.find_elements(:xpath, child_xpath)
25
- end
26
-
27
- end
28
- end
29
- end
@@ -1,31 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module SeleniumUnorderedList
4
-
5
- #
6
- # Return the PageObject::Elements::ListItem for the index provided. Index
7
- # is zero based.
8
- #
9
- # @return [PageObject::Elements::ListItem]
10
- #
11
- def [](idx)
12
- eles = list_items
13
- PageObject::Elements::ListItem.new(eles[idx], :platform => :selenium)
14
- end
15
-
16
- #
17
- # Return the number of items contained in the unordered list
18
- #
19
- def items
20
- list_items.size
21
- end
22
-
23
- private
24
-
25
- def list_items
26
- element.find_elements(:xpath, child_xpath)
27
- end
28
-
29
- end
30
- end
31
- end
@@ -1,136 +0,0 @@
1
-
2
- module PageObject
3
- module Platforms
4
- #
5
- # Watir implementation of the common functionality found across all elements
6
- #
7
- module WatirElement
8
-
9
- #
10
- # return true if an element is visible
11
- #
12
- def visible?
13
- @element.present?
14
- end
15
-
16
- #
17
- # return true if an element exists
18
- #
19
- def exists?
20
- @element.exists?
21
- end
22
-
23
- #
24
- # Get the text for the element
25
- #
26
- # @return [String]
27
- #
28
- def text
29
- @element.text
30
- end
31
-
32
- #
33
- # Get the value of this element
34
- #
35
- # @return [String]
36
- #
37
- def value
38
- @element.value
39
- end
40
-
41
- #
42
- # compare this element to another to determine if they are equal
43
- #
44
- def ==(other)
45
- @element == other.element
46
- end
47
-
48
- #
49
- # Get the tag name of this element
50
- #
51
- # @return [String]
52
- #
53
- def tag_name
54
- @element.tag_name
55
- end
56
-
57
- #
58
- # Get the value of a the given attribute of the element. Will return the current value, even if
59
- # this has been modified after the page has been loaded. More exactly, this method will return
60
- # the value of the given attribute, unless that attribute is not present, in which case the
61
- # value of the property with the same name is returned. If neither value is set, nil is
62
- # returned. The "style" attribute is converted as best can be to a text representation with a
63
- # trailing semi-colon. The following are deemed to be "boolean" attributes, and will
64
- # return either "true" or "false":
65
- #
66
- # async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
67
- # defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate,
68
- # iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate,
69
- # nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking,
70
- # selected, spellcheck, truespeed, willvalidate
71
- #
72
- # Finally, the following commonly mis-capitalized attribute/property names are evaluated as
73
- # expected:
74
- #
75
- # class, readonly
76
- #
77
- # @param [String]
78
- # attribute name
79
- # @return [String,nil]
80
- # attribute value
81
- #
82
- def attribute(attribute_name)
83
- @element.attribute_value attribute_name
84
- end
85
-
86
- #
87
- # Click this element
88
- #
89
- def click
90
- @element.click
91
- end
92
-
93
- #
94
- # Waits until the element is present
95
- #
96
- # @param [Integer] (defaults to: 5) seconds to wait before timing out
97
- #
98
- def when_present(timeout=5)
99
- @element.wait_until_present(timeout)
100
- end
101
-
102
- #
103
- # Waits until the element is visible
104
- #
105
- # @param [Integer] (defaults to: 5) seconds to wait before timing out
106
- #
107
- def when_visible(timeout=5)
108
- Watir::Wait.until(timeout, "Element was not visible in #{timeout} seconds") do
109
- visible?
110
- end
111
- end
112
-
113
- #
114
- # Waits until the element is not visible
115
- #
116
- # @param [Integer] (defaults to: 5) seconds to wait before timing out
117
- #
118
- def when_not_visible(timeout=5)
119
- Watir::Wait.while(timeout, "Element still visible after #{timeout} seconds") do
120
- visible?
121
- end
122
- end
123
-
124
- #
125
- # Waits until the block returns true
126
- #
127
- # @param [Integer] (defaults to: 5) seconds to wait before timing out
128
- # @param [String] the message to display if the event timeouts
129
- # @param the block to execute when the event occurrs
130
- #
131
- def wait_until(timeout=5, message=nil, &block)
132
- Watir::Wait.until(timeout, message, &block)
133
- end
134
- end
135
- end
136
- end
@@ -1,14 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module WatirForm
4
-
5
- #
6
- # Submit the form.
7
- #
8
- def submit
9
- @element.submit
10
- end
11
-
12
- end
13
- end
14
- end
@@ -1,20 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module WatirImage
4
-
5
- #
6
- # Return the width of the image.
7
- #
8
- def width
9
- @element.width
10
- end
11
-
12
- #
13
- # Return the height of the image
14
- #
15
- def height
16
- @element.height
17
- end
18
- end
19
- end
20
- end
@@ -1,30 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module WatirOrderedList
4
-
5
- #
6
- # Return the PageObject::Elements::ListItem for the index provided. Index
7
- # is zero based.
8
- #
9
- # @return [PageObject::Elements::ListItem]
10
- #
11
- def [](idx)
12
- eles = list_items
13
- PageObject::Elements::ListItem.new(eles[idx], :platform => :watir)
14
- end
15
-
16
- #
17
- # Return the number of items contained in the ordered list
18
- #
19
- def items
20
- list_items.size
21
- end
22
-
23
- private
24
-
25
- def list_items
26
- element.wd.find_elements(:xpath, child_xpath)
27
- end
28
- end
29
- end
30
- end
@@ -1,30 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module WatirSelectList
4
-
5
- #
6
- # Return the PageObject::Elements::Option for the index provided. Index
7
- # is zero based.
8
- #
9
- # @return [PageObject::Elements::Option]
10
- #
11
- def [](idx)
12
- PageObject::Elements::Option.new(options[idx], :platform => :watir)
13
- end
14
-
15
- #
16
- # Return an array of Options contained in the select lit.
17
- #
18
- # @return [array of PageObject::Elements::Option]
19
- #
20
- def options
21
- elements = []
22
- options = @element.wd.find_elements(:xpath, child_xpath)
23
- options.each do |opt|
24
- elements << PageObject::Elements::Option.new(opt, :platform => :watir)
25
- end
26
- elements
27
- end
28
- end
29
- end
30
- end