page-object 2.2.6 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -1
  3. data/.gitignore +8 -8
  4. data/.rspec +2 -2
  5. data/.ruby-gemset +1 -1
  6. data/.ruby-version +1 -1
  7. data/.travis.yml +17 -17
  8. data/ChangeLog +923 -916
  9. data/Gemfile +13 -13
  10. data/Guardfile +20 -20
  11. data/LICENSE +20 -20
  12. data/README.md +114 -114
  13. data/Rakefile +29 -29
  14. data/cucumber.yml +8 -8
  15. data/lib/page-object.rb +431 -420
  16. data/lib/page-object/accessors.rb +1201 -1175
  17. data/lib/page-object/element_locators.rb +21 -21
  18. data/lib/page-object/elements.rb +62 -61
  19. data/lib/page-object/elements/area.rb +9 -9
  20. data/lib/page-object/elements/audio.rb +9 -9
  21. data/lib/page-object/elements/bold.rb +9 -9
  22. data/lib/page-object/elements/button.rb +12 -12
  23. data/lib/page-object/elements/canvas.rb +10 -10
  24. data/lib/page-object/elements/check_box.rb +9 -9
  25. data/lib/page-object/elements/date_field.rb +10 -0
  26. data/lib/page-object/elements/div.rb +9 -9
  27. data/lib/page-object/elements/element.rb +212 -209
  28. data/lib/page-object/elements/file_field.rb +9 -9
  29. data/lib/page-object/elements/form.rb +9 -9
  30. data/lib/page-object/elements/heading.rb +14 -14
  31. data/lib/page-object/elements/hidden_field.rb +9 -9
  32. data/lib/page-object/elements/image.rb +10 -10
  33. data/lib/page-object/elements/italic.rb +9 -9
  34. data/lib/page-object/elements/label.rb +9 -9
  35. data/lib/page-object/elements/link.rb +9 -9
  36. data/lib/page-object/elements/list_item.rb +9 -9
  37. data/lib/page-object/elements/media.rb +11 -11
  38. data/lib/page-object/elements/option.rb +9 -9
  39. data/lib/page-object/elements/ordered_list.rb +43 -43
  40. data/lib/page-object/elements/paragraph.rb +9 -9
  41. data/lib/page-object/elements/radio_button.rb +9 -9
  42. data/lib/page-object/elements/select_list.rb +42 -42
  43. data/lib/page-object/elements/span.rb +9 -9
  44. data/lib/page-object/elements/table.rb +85 -85
  45. data/lib/page-object/elements/table_cell.rb +10 -10
  46. data/lib/page-object/elements/table_row.rb +52 -52
  47. data/lib/page-object/elements/text_area.rb +9 -9
  48. data/lib/page-object/elements/text_field.rb +10 -10
  49. data/lib/page-object/elements/unordered_list.rb +42 -42
  50. data/lib/page-object/elements/video.rb +9 -9
  51. data/lib/page-object/indexed_properties.rb +41 -41
  52. data/lib/page-object/javascript/angularjs.rb +14 -14
  53. data/lib/page-object/javascript/jquery.rb +14 -14
  54. data/lib/page-object/javascript/prototype.rb +14 -14
  55. data/lib/page-object/javascript/yui.rb +18 -18
  56. data/lib/page-object/javascript_framework_facade.rb +80 -80
  57. data/lib/page-object/locator_generator.rb +183 -182
  58. data/lib/page-object/nested_elements.rb +17 -17
  59. data/lib/page-object/page_factory.rb +108 -108
  60. data/lib/page-object/page_populator.rb +105 -105
  61. data/lib/page-object/platforms/watir.rb +50 -50
  62. data/lib/page-object/platforms/watir/page_object.rb +1155 -1124
  63. data/lib/page-object/section_collection.rb +16 -16
  64. data/lib/page-object/version.rb +4 -4
  65. data/lib/page-object/widgets.rb +98 -98
  66. data/page-object.gemspec +32 -32
  67. metadata +8 -7
@@ -1,41 +1,41 @@
1
- module PageObject
2
- module IndexedProperties
3
- class TableOfElements
4
- include PageObject
5
-
6
- def initialize (browser, identifier_list)
7
- initialize_browser(browser)
8
- @identifier_list = identifier_list
9
- @indexed_property_class = Class.new {
10
- include PageObject
11
- extend Accessors
12
-
13
- def initialize (browser, index, identifier_list)
14
- initialize_browser(browser)
15
-
16
- identifier_list.each do |identifier|
17
- type = identifier[0]
18
- name = identifier[1]
19
- how_and_what = identifier[2].clone # Cannot modify the original...
20
- how_and_what.each do |key, value|
21
- next if value.is_a? Regexp # Cannot format Regexp with %
22
- if key == :index
23
- how_and_what[key] = (value % index).to_i
24
- elsif key == :frame
25
- how_and_what[key] = value #passthrough frame without modification
26
- else
27
- how_and_what[key] = value % index
28
- end
29
- end
30
- self.class.send type, name, how_and_what unless Class.instance_methods.include? name
31
- end
32
- end
33
- }
34
- end
35
-
36
- def [] (index)
37
- @indexed_property_class.new(@browser, index, @identifier_list)
38
- end
39
- end
40
- end
41
- end
1
+ module PageObject
2
+ module IndexedProperties
3
+ class TableOfElements
4
+ include PageObject
5
+
6
+ def initialize (browser, identifier_list)
7
+ initialize_browser(browser)
8
+ @identifier_list = identifier_list
9
+ @indexed_property_class = Class.new {
10
+ include PageObject
11
+ extend Accessors
12
+
13
+ def initialize (browser, index, identifier_list)
14
+ initialize_browser(browser)
15
+
16
+ identifier_list.each do |identifier|
17
+ type = identifier[0]
18
+ name = identifier[1]
19
+ how_and_what = identifier[2].clone # Cannot modify the original...
20
+ how_and_what.each do |key, value|
21
+ next if value.is_a? Regexp # Cannot format Regexp with %
22
+ if key == :index
23
+ how_and_what[key] = (value % index).to_i
24
+ elsif key == :frame
25
+ how_and_what[key] = value #passthrough frame without modification
26
+ else
27
+ how_and_what[key] = value % index
28
+ end
29
+ end
30
+ self.class.send type, name, how_and_what unless Class.instance_methods.include? name
31
+ end
32
+ end
33
+ }
34
+ end
35
+
36
+ def [] (index)
37
+ @indexed_property_class.new(@browser, index, @identifier_list)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,14 +1,14 @@
1
- module PageObject
2
- module Javascript
3
-
4
- module AngularJS
5
- #
6
- # return the number of pending ajax requests
7
- #
8
- def self.pending_requests
9
- 'return angular.element(document.body).injector().get(\'$http\').pendingRequests.length;'
10
- end
11
- end
12
-
13
- end
14
- end
1
+ module PageObject
2
+ module Javascript
3
+
4
+ module AngularJS
5
+ #
6
+ # return the number of pending ajax requests
7
+ #
8
+ def self.pending_requests
9
+ 'return angular.element(document.body).injector().get(\'$http\').pendingRequests.length;'
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -1,14 +1,14 @@
1
- module PageObject
2
- module Javascript
3
-
4
- module JQuery
5
- #
6
- # return the number of pending ajax requests
7
- #
8
- def self.pending_requests
9
- 'return jQuery.active'
10
- end
11
- end
12
-
13
- end
14
- end
1
+ module PageObject
2
+ module Javascript
3
+
4
+ module JQuery
5
+ #
6
+ # return the number of pending ajax requests
7
+ #
8
+ def self.pending_requests
9
+ 'return jQuery.active'
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -1,14 +1,14 @@
1
- module PageObject
2
- module Javascript
3
-
4
- module Prototype
5
- #
6
- # return the number of pending ajax requests
7
- #
8
- def self.pending_requests
9
- 'return Ajax.activeRequestCount'
10
- end
11
- end
12
-
13
- end
14
- end
1
+ module PageObject
2
+ module Javascript
3
+
4
+ module Prototype
5
+ #
6
+ # return the number of pending ajax requests
7
+ #
8
+ def self.pending_requests
9
+ 'return Ajax.activeRequestCount'
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -1,19 +1,19 @@
1
- module PageObject
2
- module Javascript
3
-
4
- module YUI
5
- #
6
- # return the number of pending ajax requests
7
- #
8
- def self.pending_requests
9
- "var inProgress=0
10
- for(var i=0; i < YAHOO.util.Connect._transaction_id; i++) {
11
- if(YAHOO.util.Connect.isCallInProgress(i))
12
- inProgress++;
13
- }
14
- return inProgress;"
15
- end
16
- end
17
-
18
- end
1
+ module PageObject
2
+ module Javascript
3
+
4
+ module YUI
5
+ #
6
+ # return the number of pending ajax requests
7
+ #
8
+ def self.pending_requests
9
+ "var inProgress=0
10
+ for(var i=0; i < YAHOO.util.Connect._transaction_id; i++) {
11
+ if(YAHOO.util.Connect.isCallInProgress(i))
12
+ inProgress++;
13
+ }
14
+ return inProgress;"
15
+ end
16
+ end
17
+
18
+ end
19
19
  end
@@ -1,80 +1,80 @@
1
- require 'page-object/javascript/jquery'
2
- require 'page-object/javascript/prototype'
3
- require 'page-object/javascript/yui'
4
- require 'page-object/javascript/angularjs'
5
-
6
-
7
- module PageObject
8
- #
9
- # Provide hooks into different common Javascript Frameworks.
10
- # Currently this module only supports jQuery and Prototype but it
11
- # has the ability for you to plug your own framework into it and
12
- # therefore have it work with this gem. You do this by calling the
13
- # #add_framework method. The module you provide must implement the
14
- # necessary methods. Please look at the jQuery or Prototype
15
- # implementations to determine the necessary methods
16
- #
17
- module JavascriptFrameworkFacade
18
-
19
- class << self
20
- #
21
- # Set the framework to use.
22
- #
23
- # @param[Symbol] the framework to use. :jquery, :prototype, :yui,
24
- # and :angularjs are supported
25
- #
26
- def framework=(framework)
27
- initialize_script_builder unless @builder
28
- raise unknown_framework(framework) unless @builder[framework]
29
- @framework = framework
30
- end
31
-
32
- #
33
- # Get the framework that will be used
34
- #
35
- def framework
36
- @framework
37
- end
38
-
39
- #
40
- # Add a framework and make it available to the system.
41
- #
42
- def add_framework(key, value)
43
- raise invalid_framework unless value.respond_to? :pending_requests
44
- initialize_script_builder unless @builder
45
- @builder[key] = value
46
- end
47
-
48
- #
49
- # get the javascript to determine number of pending requests
50
- #
51
- def pending_requests
52
- script_builder.pending_requests
53
- end
54
-
55
- def script_builder
56
- initialize_script_builder unless @builder
57
- @builder[@framework]
58
- end
59
-
60
- private
61
-
62
- def initialize_script_builder
63
- @builder = {
64
- :jquery => ::PageObject::Javascript::JQuery,
65
- :prototype => ::PageObject::Javascript::Prototype,
66
- :yui => ::PageObject::Javascript::YUI,
67
- :angularjs => ::PageObject::Javascript::AngularJS
68
- }
69
- end
70
-
71
- def unknown_framework(framework)
72
- "You specified the Javascript framework #{framework} and it is unknown to the system"
73
- end
74
-
75
- def invalid_framework
76
- "The Javascript framework you provided does not implement the necessary methods"
77
- end
78
- end
79
- end
80
- end
1
+ require 'page-object/javascript/jquery'
2
+ require 'page-object/javascript/prototype'
3
+ require 'page-object/javascript/yui'
4
+ require 'page-object/javascript/angularjs'
5
+
6
+
7
+ module PageObject
8
+ #
9
+ # Provide hooks into different common Javascript Frameworks.
10
+ # Currently this module only supports jQuery and Prototype but it
11
+ # has the ability for you to plug your own framework into it and
12
+ # therefore have it work with this gem. You do this by calling the
13
+ # #add_framework method. The module you provide must implement the
14
+ # necessary methods. Please look at the jQuery or Prototype
15
+ # implementations to determine the necessary methods
16
+ #
17
+ module JavascriptFrameworkFacade
18
+
19
+ class << self
20
+ #
21
+ # Set the framework to use.
22
+ #
23
+ # @param[Symbol] the framework to use. :jquery, :prototype, :yui,
24
+ # and :angularjs are supported
25
+ #
26
+ def framework=(framework)
27
+ initialize_script_builder unless @builder
28
+ raise unknown_framework(framework) unless @builder[framework]
29
+ @framework = framework
30
+ end
31
+
32
+ #
33
+ # Get the framework that will be used
34
+ #
35
+ def framework
36
+ @framework
37
+ end
38
+
39
+ #
40
+ # Add a framework and make it available to the system.
41
+ #
42
+ def add_framework(key, value)
43
+ raise invalid_framework unless value.respond_to? :pending_requests
44
+ initialize_script_builder unless @builder
45
+ @builder[key] = value
46
+ end
47
+
48
+ #
49
+ # get the javascript to determine number of pending requests
50
+ #
51
+ def pending_requests
52
+ script_builder.pending_requests
53
+ end
54
+
55
+ def script_builder
56
+ initialize_script_builder unless @builder
57
+ @builder[@framework]
58
+ end
59
+
60
+ private
61
+
62
+ def initialize_script_builder
63
+ @builder = {
64
+ :jquery => ::PageObject::Javascript::JQuery,
65
+ :prototype => ::PageObject::Javascript::Prototype,
66
+ :yui => ::PageObject::Javascript::YUI,
67
+ :angularjs => ::PageObject::Javascript::AngularJS
68
+ }
69
+ end
70
+
71
+ def unknown_framework(framework)
72
+ "You specified the Javascript framework #{framework} and it is unknown to the system"
73
+ end
74
+
75
+ def invalid_framework
76
+ "The Javascript framework you provided does not implement the necessary methods"
77
+ end
78
+ end
79
+ end
80
+ end
@@ -1,182 +1,183 @@
1
- module PageObject
2
- module LocatorGenerator
3
-
4
- BASIC_ELEMENTS = %i(
5
- abbr
6
- address
7
- animate
8
- animate_motion
9
- animate_transform
10
- article
11
- as
12
- aside
13
- base
14
- bdi
15
- bdo
16
- blockquote
17
- body
18
- br
19
- caption
20
- circle
21
- cite
22
- code
23
- col
24
- colgroup
25
- command
26
- cursor
27
- data
28
- datalist
29
- dd
30
- defs
31
- del
32
- desc
33
- details
34
- dfn
35
- dialog
36
- discard
37
- dl
38
- dt
39
- ellipse
40
- em
41
- embed
42
- fieldset
43
- figcaption
44
- figure
45
- font
46
- footer
47
- foreign_object
48
- g
49
- head
50
- header
51
- hgroup
52
- hr
53
- html
54
- ins
55
- kbd
56
- keygen
57
- legend
58
- line
59
- linear_gradient
60
- main
61
- map
62
- mark
63
- marker
64
- menu
65
- menuitem
66
- mesh_gradient
67
- mesh_patch
68
- mesh_row
69
- meta
70
- metadata
71
- meter
72
- mpath
73
- nav
74
- noscript
75
- object
76
- optgroup
77
- output
78
- p
79
- param
80
- path
81
- pattern
82
- polygon
83
- polyline
84
- pre
85
- progress
86
- q
87
- radial_gradient
88
- rect
89
- rp
90
- rt
91
- ruby
92
- s
93
- samp
94
- script
95
- section
96
- set
97
- small
98
- source
99
- stop
100
- strong
101
- style
102
- sub
103
- summary
104
- sup
105
- switch
106
- symbol
107
- template
108
- text_path
109
- thread
110
- time
111
- title
112
- track
113
- tspan
114
- u
115
- use
116
- var
117
- view
118
- wbr
119
- )
120
-
121
-
122
- ADVANCED_ELEMENTS = %i(
123
- text_field
124
- hidden_field
125
- text_area
126
- select_list
127
- link
128
- checkbox
129
- radio_button
130
- button
131
- div
132
- span
133
- table
134
- cell
135
- row
136
- image
137
- form
138
- list_item
139
- ordered_list
140
- unordered_list
141
- h1
142
- h2
143
- h3
144
- h4
145
- h5
146
- h6
147
- paragraph
148
- label
149
- file_field
150
- area
151
- canvas
152
- audio
153
- video
154
- b
155
- i
156
- svg
157
- )
158
-
159
- def self.generate_locators(target)
160
- ADVANCED_ELEMENTS.each do |tag|
161
- target.send(:define_method, "#{tag.to_s}_element") do |*identifier|
162
- @platform.send "#{tag.to_s}_for", locator(identifier)
163
- end
164
-
165
- target.send(:define_method, "#{tag.to_s}_elements") do |*identifier|
166
- @platform.send("#{tag.to_s}s_for", identifier[0] ? identifier[0] : {})
167
- end
168
- end
169
-
170
- BASIC_ELEMENTS.each do |tag|
171
- target.send(:define_method, "#{tag.to_s}_element") do |*identifier|
172
- @platform.send :element_for, tag, locator(identifier)
173
- end
174
-
175
- target.send(:define_method, "#{tag.to_s}_elements") do |*identifier|
176
- @platform.send(:elements_for, tag, identifier[0] ? identifier[0] : {})
177
- end
178
- end
179
- end
180
-
181
- end
182
- end
1
+ module PageObject
2
+ module LocatorGenerator
3
+
4
+ BASIC_ELEMENTS = %i(
5
+ abbr
6
+ address
7
+ animate
8
+ animate_motion
9
+ animate_transform
10
+ article
11
+ as
12
+ aside
13
+ base
14
+ bdi
15
+ bdo
16
+ blockquote
17
+ body
18
+ br
19
+ caption
20
+ circle
21
+ cite
22
+ code
23
+ col
24
+ colgroup
25
+ command
26
+ cursor
27
+ data
28
+ datalist
29
+ dd
30
+ defs
31
+ del
32
+ desc
33
+ details
34
+ dfn
35
+ dialog
36
+ discard
37
+ dl
38
+ dt
39
+ ellipse
40
+ em
41
+ embed
42
+ fieldset
43
+ figcaption
44
+ figure
45
+ font
46
+ footer
47
+ foreign_object
48
+ g
49
+ head
50
+ header
51
+ hgroup
52
+ hr
53
+ html
54
+ ins
55
+ kbd
56
+ keygen
57
+ legend
58
+ line
59
+ linear_gradient
60
+ main
61
+ map
62
+ mark
63
+ marker
64
+ menu
65
+ menuitem
66
+ mesh_gradient
67
+ mesh_patch
68
+ mesh_row
69
+ meta
70
+ metadata
71
+ meter
72
+ mpath
73
+ nav
74
+ noscript
75
+ object
76
+ optgroup
77
+ output
78
+ p
79
+ param
80
+ path
81
+ pattern
82
+ polygon
83
+ polyline
84
+ pre
85
+ progress
86
+ q
87
+ radial_gradient
88
+ rect
89
+ rp
90
+ rt
91
+ ruby
92
+ s
93
+ samp
94
+ script
95
+ section
96
+ set
97
+ small
98
+ source
99
+ stop
100
+ strong
101
+ style
102
+ sub
103
+ summary
104
+ sup
105
+ switch
106
+ symbol
107
+ template
108
+ text_path
109
+ thread
110
+ time
111
+ title
112
+ track
113
+ tspan
114
+ u
115
+ use
116
+ var
117
+ view
118
+ wbr
119
+ )
120
+
121
+
122
+ ADVANCED_ELEMENTS = %i(
123
+ text_field
124
+ date_field
125
+ hidden_field
126
+ text_area
127
+ select_list
128
+ link
129
+ checkbox
130
+ radio_button
131
+ button
132
+ div
133
+ span
134
+ table
135
+ cell
136
+ row
137
+ image
138
+ form
139
+ list_item
140
+ ordered_list
141
+ unordered_list
142
+ h1
143
+ h2
144
+ h3
145
+ h4
146
+ h5
147
+ h6
148
+ paragraph
149
+ label
150
+ file_field
151
+ area
152
+ canvas
153
+ audio
154
+ video
155
+ b
156
+ i
157
+ svg
158
+ )
159
+
160
+ def self.generate_locators(target)
161
+ ADVANCED_ELEMENTS.each do |tag|
162
+ target.send(:define_method, "#{tag.to_s}_element") do |*identifier|
163
+ @platform.send "#{tag.to_s}_for", locator(identifier)
164
+ end
165
+
166
+ target.send(:define_method, "#{tag.to_s}_elements") do |*identifier|
167
+ @platform.send("#{tag.to_s}s_for", identifier[0] ? identifier[0] : {})
168
+ end
169
+ end
170
+
171
+ BASIC_ELEMENTS.each do |tag|
172
+ target.send(:define_method, "#{tag.to_s}_element") do |*identifier|
173
+ @platform.send :element_for, tag, locator(identifier)
174
+ end
175
+
176
+ target.send(:define_method, "#{tag.to_s}_elements") do |*identifier|
177
+ @platform.send(:elements_for, tag, identifier[0] ? identifier[0] : {})
178
+ end
179
+ end
180
+ end
181
+
182
+ end
183
+ end