page-object 2.2 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -12
  3. data/ChangeLog +7 -0
  4. data/lib/page-object.rb +1 -1
  5. data/lib/page-object/elements/area.rb +0 -22
  6. data/lib/page-object/elements/audio.rb +1 -1
  7. data/lib/page-object/elements/bold.rb +0 -1
  8. data/lib/page-object/elements/button.rb +0 -1
  9. data/lib/page-object/elements/canvas.rb +1 -2
  10. data/lib/page-object/elements/check_box.rb +0 -22
  11. data/lib/page-object/elements/div.rb +1 -0
  12. data/lib/page-object/elements/element.rb +5 -104
  13. data/lib/page-object/elements/file_field.rb +0 -9
  14. data/lib/page-object/elements/form.rb +0 -1
  15. data/lib/page-object/elements/heading.rb +0 -1
  16. data/lib/page-object/elements/hidden_field.rb +0 -4
  17. data/lib/page-object/elements/image.rb +0 -14
  18. data/lib/page-object/elements/italic.rb +0 -2
  19. data/lib/page-object/elements/link.rb +0 -2
  20. data/lib/page-object/elements/list_item.rb +0 -1
  21. data/lib/page-object/elements/media.rb +0 -34
  22. data/lib/page-object/elements/option.rb +0 -1
  23. data/lib/page-object/elements/ordered_list.rb +6 -19
  24. data/lib/page-object/elements/radio_button.rb +0 -15
  25. data/lib/page-object/elements/select_list.rb +2 -17
  26. data/lib/page-object/elements/span.rb +0 -1
  27. data/lib/page-object/elements/table.rb +18 -37
  28. data/lib/page-object/elements/table_cell.rb +0 -8
  29. data/lib/page-object/elements/table_row.rb +14 -24
  30. data/lib/page-object/elements/text_area.rb +0 -9
  31. data/lib/page-object/elements/text_field.rb +0 -8
  32. data/lib/page-object/elements/unordered_list.rb +6 -22
  33. data/lib/page-object/elements/video.rb +1 -0
  34. data/lib/page-object/page_populator.rb +5 -8
  35. data/lib/page-object/platforms/watir.rb +2 -2
  36. data/lib/page-object/platforms/watir/page_object.rb +1 -2
  37. data/lib/page-object/version.rb +1 -1
  38. data/page-object.gemspec +2 -1
  39. metadata +18 -5
  40. data/lib/page-object/core_ext/string.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a9026e5a1dfab04ad9562d3e2c1ff46224809d3
4
- data.tar.gz: b64e10f88d26956b50be3feb5a41627f40dc2378
3
+ metadata.gz: ed39bfdc657310a484fdead50fb7a3d060358a48
4
+ data.tar.gz: 50e8d4e3a1c2669e0c2e3709372ae1c4422aa701
5
5
  SHA512:
6
- metadata.gz: d780f2a594808da6f2bc24a6560c6a56bff7868600a6d025d91c98e68571c9bb85626c42a47a46983dd213ec9f84576f390f1dec987ee8dcc817d337131d1be7
7
- data.tar.gz: 5af925dc3bcdf8d3bca259d53f4e88b75b258e7f0601004a02b8f55d533a82eebc25292c016dc5751bd488d303aef25fa96d0cd6dfc661a6c86a2833314733e5
6
+ metadata.gz: 79ca96731f54acc6e6bda50b0f6aea7b7a1d1ca830eb7ebdd0f2bd6625779bdf55a210d8ca80e5f3be2d860c9f821042e7284e33959f090247f28d38e1963257
7
+ data.tar.gz: f7ffaa56092110c6f7abe3a2a30fa39157ba71fc001b56c428a5d2f9d8453c8059f54a8a80ea8ce89423bc7e8417b925042960869c132cb5f924ec0450d854d6
@@ -1,22 +1,15 @@
1
1
  sudo: required
2
2
  dist: trusty
3
3
  rvm:
4
- - 2.2.5
5
- - 2.3.1
4
+ - 2.2.7
5
+ - 2.3.4
6
+ - 2.4.1
6
7
  cache: bundler
8
+ addons:
9
+ chrome: stable
7
10
  before_script:
8
- - export CHROME_BIN=/usr/bin/google-chrome
9
11
  - export DISPLAY=:99.0
10
12
  - sh -e /etc/init.d/xvfb start
11
- - sudo apt-get update
12
- - sudo apt-get install -y libappindicator1 fonts-liberation
13
- - wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
14
- - sudo dpkg -i google-chrome*.deb
15
- - CHROMEDRIVER_VERSION=$(curl -s http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
16
- - curl -L -O "http://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip"
17
- - unzip chromedriver_linux64.zip
18
- - chmod +x chromedriver
19
- - sudo mv chromedriver /usr/local/bin
20
13
 
21
14
  script: bundle exec rake $RAKE_TASK
22
15
  env:
data/ChangeLog CHANGED
@@ -1,3 +1,10 @@
1
+ Version 2.2.1 / 2017-9-22
2
+ * Enhancements
3
+ * Moved some functionality from PageObject to Watir (Thanks Titus Fortner)
4
+ * Fixes
5
+ * Fixed bug when selection option by text with populate_page_with (Thanks Jason Phebus)
6
+ * Fixed issue with wrapping the Selenium driver with Watir (Thanks Titus Fortner)
7
+
1
8
  Version 2.2 / 2017-8-4
2
9
  * Enhancements
3
10
  * when_visible and when_not_visible now wait for element to be present before checking
@@ -76,7 +76,7 @@ module PageObject
76
76
  def initialize_browser(root)
77
77
  @root_element = PageObject::Platforms::Watir.root_element_for root
78
78
  @browser = root
79
- @platform = PageObject::Platforms::Watir::PageObject.new @browser
79
+ @platform = PageObject::Platforms::Watir.create_page_object @browser
80
80
  end
81
81
 
82
82
  # @private
@@ -1,29 +1,7 @@
1
-
2
1
  module PageObject
3
2
  module Elements
4
3
  class Area < Element
5
4
 
6
- #
7
- # return the coordinates of the area
8
- #
9
- def coords
10
- attribute(:coords)
11
- end
12
-
13
- #
14
- # return the shape of the area
15
- #
16
- def shape
17
- attribute(:shape)
18
- end
19
-
20
- #
21
- # return the href of the area
22
- #
23
- def href
24
- attribute(:href)
25
- end
26
-
27
5
  end
28
6
 
29
7
  ::PageObject::Elements.type_to_class[:area] = ::PageObject::Elements::Area
@@ -1,9 +1,9 @@
1
-
2
1
  module PageObject
3
2
  module Elements
4
3
  class Audio < Media
5
4
 
6
5
  end
6
+
7
7
  ::PageObject::Elements.type_to_class[:audio] = ::PageObject::Elements::Audio
8
8
  end
9
9
  end
@@ -5,6 +5,5 @@ module PageObject
5
5
  end
6
6
 
7
7
  ::PageObject::Elements.tag_to_class[:b] = ::PageObject::Elements::Bold
8
-
9
8
  end
10
9
  end
@@ -1,4 +1,3 @@
1
-
2
1
  module PageObject
3
2
  module Elements
4
3
  class Button < Element
@@ -1,10 +1,9 @@
1
-
2
1
  module PageObject
3
2
  module Elements
4
3
  class Canvas < Element
5
4
 
6
-
7
5
  end
6
+
8
7
  ::PageObject::Elements.type_to_class[:canvas] = ::PageObject::Elements::Canvas
9
8
  end
10
9
  end
@@ -2,30 +2,8 @@ module PageObject
2
2
  module Elements
3
3
  class CheckBox < Element
4
4
 
5
- #
6
- # check the checkbox
7
- #
8
- def check
9
- element.set
10
- end
11
-
12
- #
13
- # uncheck the checkbox
14
- #
15
- def uncheck
16
- element.clear
17
- end
18
-
19
- #
20
- # return true if checkbox is checked
21
- #
22
- def checked?
23
- element.set?
24
- end
25
-
26
5
  end
27
6
 
28
7
  ::PageObject::Elements.type_to_class[:checkbox] = ::PageObject::Elements::CheckBox
29
-
30
8
  end
31
9
  end
@@ -1,6 +1,7 @@
1
1
  module PageObject
2
2
  module Elements
3
3
  class Div < Element
4
+
4
5
  end
5
6
 
6
7
  ::PageObject::Elements.tag_to_class[:div] = ::PageObject::Elements::Div
@@ -25,18 +25,6 @@ module PageObject
25
25
  not enabled?
26
26
  end
27
27
 
28
-
29
- def inspect
30
- element.inspect
31
- end
32
-
33
- #
34
- # retrieve the class name for an element
35
- #
36
- def class_name
37
- attribute 'class'
38
- end
39
-
40
28
  #
41
29
  # specify plural form of element
42
30
  #
@@ -70,13 +58,6 @@ module PageObject
70
58
  end
71
59
  end
72
60
 
73
- #
74
- # return true if an element is visible
75
- #
76
- # def visible?
77
- # element.present?
78
- # end
79
-
80
61
  #
81
62
  # compare this element to another to determine if they are equal
82
63
  #
@@ -84,48 +65,14 @@ module PageObject
84
65
  other.is_a? self.class and element == other.element
85
66
  end
86
67
 
87
- #
88
- # Get the value of a the given attribute of the element. Will
89
- # return the current value, even if this has been modified
90
- # after the page has been loaded. More exactly, this method
91
- # will return the value of the given attribute, unless that
92
- # attribute is not present, in which case the value of the
93
- # property with the same name is returned. If neither value is
94
- # set, nil is returned. The "style" attribute is converted as
95
- # best can be to a text representation with a trailing
96
- # semi-colon. The following are deemed to be "boolean"
97
- # attributes, and will return either "true" or "false":
98
- #
99
- # async, autofocus, autoplay, checked, compact, complete,
100
- # controls, declare, defaultchecked, defaultselected, defer,
101
- # disabled, draggable, ended, formnovalidate, hidden, indeterminate,
102
- # iscontenteditable, ismap, itemscope, loop, multiple, muted,
103
- # nohref, noresize, noshade, novalidate, nowrap, open, paused,
104
- # pubdate, readonly, required, reversed, scoped, seamless, seeking,
105
- # selected, spellcheck, truespeed, willvalidate
106
- #
107
- # Finally, the following commonly mis-capitalized
108
- # attribute/property names are evaluated as expected:
109
- #
110
- # class, readonly
111
- #
112
- # @param [String]
113
- # attribute name
114
- # @return [String,nil]
115
- # attribute value
116
- #
117
- def attribute(attribute_name)
118
- element.attribute_value attribute_name
119
- end
120
-
121
68
  #
122
69
  # find the parent element
123
70
  #
124
- def parent
125
- parent = element.parent
71
+ def parent(opt = {})
72
+ parent = element.parent(opt)
126
73
  type = element.type if parent.tag_name.to_sym == :input
127
74
  cls = ::PageObject::Elements.element_class_for(parent.tag_name, type)
128
- cls.new(parent)
75
+ cls.new(parent.to_subtype)
129
76
  end
130
77
 
131
78
  #
@@ -180,48 +127,8 @@ module PageObject
180
127
  element.wait_until(timeout: timeout, message: message, &block)
181
128
  end
182
129
 
183
- #
184
- # Scroll until the element is viewable
185
- #
186
- def scroll_into_view
187
- element.wd.location_once_scrolled_into_view
188
- end
189
-
190
- #
191
- # location of element (x, y)
192
- #
193
- def location
194
- element.wd.location
195
- end
196
-
197
- #
198
- # size of element (width, height)
199
- #
200
- def size
201
- element.wd.size
202
- end
203
-
204
- #
205
- # Get height of element
206
- #
207
- def height
208
- element.wd.size['height']
209
- end
210
-
211
- #
212
- # Get width of element
213
- #
214
- def width
215
- element.wd.size['width']
216
- end
217
-
218
- #
219
- # Get centre coordinates of element
220
- #
221
- def centre
222
- location = element.wd.location
223
- size = element.wd.size
224
- {'y' => (location['y'] + (size['height']/2)), 'x' => (location['x'] + (size['width']/2))}
130
+ def name
131
+ element.attribute(:name)
225
132
  end
226
133
 
227
134
  # @private
@@ -235,12 +142,6 @@ module PageObject
235
142
  element.respond_to?(m) || super
236
143
  end
237
144
 
238
- protected
239
-
240
- def to_ary
241
- nil
242
- end
243
-
244
145
  private
245
146
 
246
147
  def timed_loop(timeout)
@@ -1,18 +1,9 @@
1
-
2
1
  module PageObject
3
2
  module Elements
4
3
  class FileField < Element
5
4
 
6
- #
7
- # Set the value of the FileField
8
- #
9
- def value=(new_value)
10
- element.set(new_value)
11
- end
12
-
13
5
  end
14
6
 
15
7
  ::PageObject::Elements.type_to_class[:file] = ::PageObject::Elements::FileField
16
-
17
8
  end
18
9
  end
@@ -1,4 +1,3 @@
1
-
2
1
  module PageObject
3
2
  module Elements
4
3
  class Form < Element
@@ -10,6 +10,5 @@ module PageObject
10
10
  ::PageObject::Elements.tag_to_class[:h4] = ::PageObject::Elements::Heading
11
11
  ::PageObject::Elements.tag_to_class[:h5] = ::PageObject::Elements::Heading
12
12
  ::PageObject::Elements.tag_to_class[:h6] = ::PageObject::Elements::Heading
13
-
14
13
  end
15
14
  end
@@ -2,10 +2,6 @@ module PageObject
2
2
  module Elements
3
3
  class HiddenField < Element
4
4
 
5
- def click
6
- raise "click is not available on the hidden field element"
7
- end
8
-
9
5
  end
10
6
 
11
7
  ::PageObject::Elements.type_to_class[:hidden] = ::PageObject::Elements::HiddenField
@@ -2,20 +2,6 @@ module PageObject
2
2
  module Elements
3
3
  class Image < Element
4
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
-
19
5
  end
20
6
 
21
7
  ::PageObject::Elements.tag_to_class[:img] = ::PageObject::Elements::Image
@@ -5,7 +5,5 @@ module PageObject
5
5
  end
6
6
 
7
7
  ::PageObject::Elements.tag_to_class[:i] = ::PageObject::Elements::Italic
8
-
9
-
10
8
  end
11
9
  end
@@ -1,4 +1,3 @@
1
-
2
1
  module PageObject
3
2
  module Elements
4
3
  class Link < Element
@@ -6,6 +5,5 @@ module PageObject
6
5
  end
7
6
 
8
7
  ::PageObject::Elements.tag_to_class[:a] = ::PageObject::Elements::Link
9
-
10
8
  end
11
9
  end
@@ -5,6 +5,5 @@ module PageObject
5
5
  end
6
6
 
7
7
  ::PageObject::Elements.tag_to_class[:li] = ::PageObject::Elements::ListItem
8
-
9
8
  end
10
9
  end
@@ -1,45 +1,11 @@
1
-
2
1
  module PageObject
3
2
  module Elements
4
3
  class Media < Element
5
4
 
6
- def autoplay?
7
- attribute(:autoplay)
8
- end
9
-
10
5
  def has_controls?
11
6
  attribute(:controls)
12
7
  end
13
8
 
14
- def paused?
15
- attribute(:paused)
16
- end
17
-
18
- def duration
19
- duration = attribute(:duration)
20
- return duration.to_f if duration
21
- end
22
-
23
- def volume
24
- volume = attribute(:volume)
25
- return volume.to_i if volume
26
- end
27
-
28
- def ended?
29
- attribute(:ended)
30
- end
31
-
32
- def seeking?
33
- attribute(:seeking)
34
- end
35
-
36
- def loop?
37
- attribute(:loop)
38
- end
39
-
40
- def muted?
41
- attribute(:muted)
42
- end
43
9
  end
44
10
  end
45
11
  end
@@ -5,6 +5,5 @@ module PageObject
5
5
  end
6
6
 
7
7
  ::PageObject::Elements.tag_to_class[:option] = ::PageObject::Elements::Option
8
-
9
8
  end
10
9
  end
@@ -9,10 +9,8 @@ module PageObject
9
9
  #
10
10
  # @return [PageObject::Elements::ListItem]
11
11
  #
12
- def each
13
- for index in 1..self.items do
14
- yield self[index-1]
15
- end
12
+ def each(&block)
13
+ list_items.each(&block)
16
14
  end
17
15
 
18
16
  #
@@ -22,35 +20,24 @@ module PageObject
22
20
  # @return [PageObject::Elements::ListItem]
23
21
  #
24
22
  def [](idx)
25
- Object::PageObject::Elements::ListItem.new(children[idx])
23
+ list_items[idx]
26
24
  end
27
25
 
28
26
  #
29
27
  # Return the number of items contained in the ordered list
30
28
  #
31
29
  def items
32
- children.size
30
+ list_items.size
33
31
  end
34
32
 
35
33
  #
36
- # Return the ListItem objects that are children of the OrderedList
34
+ # Return Array of ListItem objects that are children of the OrderedList
37
35
  #
38
36
  def list_items
39
- children.collect do |obj|
37
+ @list_items ||= children(tag_name: 'li').map do |obj|
40
38
  Object::PageObject::Elements::ListItem.new(obj)
41
39
  end
42
40
  end
43
-
44
- protected
45
-
46
- def children
47
- element.ols(:xpath => child_xpath)
48
- end
49
-
50
- def child_xpath
51
- "./child::li"
52
- end
53
-
54
41
  end
55
42
 
56
43
  ::PageObject::Elements.tag_to_class[:ol] = ::PageObject::Elements::OrderedList
@@ -1,22 +1,7 @@
1
-
2
1
  module PageObject
3
2
  module Elements
4
3
  class RadioButton < Element
5
4
 
6
- #
7
- # select the radiobutton
8
- #
9
- def select
10
- element.set
11
- end
12
-
13
- #
14
- # return if it is selected
15
- #
16
- def selected?
17
- element.set?
18
- end
19
-
20
5
  end
21
6
 
22
7
  ::PageObject::Elements.type_to_class[:radio] = ::PageObject::Elements::RadioButton
@@ -25,29 +25,14 @@ module PageObject
25
25
  # @return [Array<String>] An array of strings representing the text of the currently selected options.
26
26
  #
27
27
  def selected_options
28
- element.selected_options.map { |e| e.text }.compact
28
+ element.selected_options.map(&:text).compact
29
29
  end
30
30
 
31
31
  #
32
32
  # @return [Array<String>] An array of strings representing the value of the currently selected options.
33
33
  #
34
34
  def selected_values
35
- element.selected_options.map { |e| e.value }.compact
36
- end
37
-
38
- #
39
- # Returns true if the select list has one or more options where text or label matches the given value.
40
- #
41
- # @param [String, Regexp] value A value.
42
- # @return [Boolean]
43
- def include?(value)
44
- element.include? value
45
- end
46
-
47
- protected
48
-
49
- def child_xpath
50
- ".//child::option"
35
+ element.selected_options.map(&:value).compact
51
36
  end
52
37
 
53
38
  end
@@ -5,6 +5,5 @@ module PageObject
5
5
  end
6
6
 
7
7
  ::PageObject::Elements.tag_to_class[:span] = ::PageObject::Elements::Span
8
-
9
8
  end
10
9
  end
@@ -8,20 +8,11 @@ module PageObject
8
8
  #
9
9
  # @return [PageObject::Elements::TableRow]
10
10
  #
11
- def each
12
- for index in 1..self.rows do
13
- yield self[index-1]
14
- end
11
+ def each(&block)
12
+ row_items.each(&block)
15
13
  end
16
14
 
17
- #
18
- # return the first row
19
- #
20
- # @return PageObject::Elements::TableRow
21
- #
22
- def first_row
23
- self[0]
24
- end
15
+ alias_method :first_row, :first
25
16
 
26
17
  #
27
18
  # return the last row
@@ -32,18 +23,6 @@ module PageObject
32
23
  self[-1]
33
24
  end
34
25
 
35
- #
36
- # return the table as hashes
37
- #
38
- # @return Hash
39
- #
40
- def hashes
41
- headers = self.first_row.map(&:text)
42
- self.entries[1..-1].map do |row|
43
- Hash[headers.zip(row.map(&:text))]
44
- end
45
- end
46
-
47
26
  #
48
27
  # Return the PageObject::Elements::TableRow for the index provided. Index
49
28
  # is zero based. If the index provided is a String then it
@@ -51,35 +30,37 @@ module PageObject
51
30
  #
52
31
  # @return [PageObject::Elements::TableRow]
53
32
  #
54
- def [](idx)
55
- idx = find_index_by_title(idx) if idx.kind_of?(String)
56
- return nil unless idx
57
- initialize_row(element[idx])
33
+ def [](what)
34
+ idx = find_index(what)
35
+ idx && row_items[idx]
58
36
  end
59
37
 
60
38
  #
61
39
  # Returns the number of rows in the table.
62
40
  #
63
41
  def rows
64
- element.wd.find_elements(:xpath, child_xpath).size
42
+ row_items.size
65
43
  end
66
44
 
67
45
  protected
68
46
 
69
- def child_xpath
70
- ".//child::tr"
47
+ def row_items
48
+ meth = strategy == :descendants ? :trs : :rows
49
+ @row_items ||= element.send(meth).map do |obj|
50
+ ::PageObject::Elements::TableRow.new(obj)
51
+ end
71
52
  end
72
53
 
73
- def initialize_row(row_element)
74
- ::PageObject::Elements::TableRow.new(row_element)
54
+ def strategy
55
+ :children
75
56
  end
76
57
 
77
- def find_index_by_title(row_title)
78
- element.rows.find_index do |row|
79
- row.cells.any? { |col| col.text.include? row_title }
58
+ def find_index(what)
59
+ return what if what.is_a? Integer
60
+ row_items.find_index do |row|
61
+ row.cell(text: /#{what}/).exist?
80
62
  end
81
63
  end
82
-
83
64
  end
84
65
 
85
66
  ::PageObject::Elements.tag_to_class[:table] = ::PageObject::Elements::Table
@@ -2,17 +2,9 @@ module PageObject
2
2
  module Elements
3
3
  class TableCell < Element
4
4
 
5
- #
6
- # return true if the element is enabled
7
- #
8
- def enabled?
9
- true
10
- end
11
-
12
5
  end
13
6
 
14
7
  ::PageObject::Elements.tag_to_class[:td] = ::PageObject::Elements::TableCell
15
8
  ::PageObject::Elements.tag_to_class[:th] = ::PageObject::Elements::TableCell
16
-
17
9
  end
18
10
  end
@@ -8,12 +8,8 @@ module PageObject
8
8
  #
9
9
  # iterator that yields with a PageObject::Elements::TableCell
10
10
  #
11
- # @return [PageObject::Elements::TableCell]
12
- #
13
- def each
14
- for index in 1..self.columns do
15
- yield self[index-1]
16
- end
11
+ def each(&block)
12
+ cell_items.each(&block)
17
13
  end
18
14
 
19
15
  #
@@ -22,39 +18,33 @@ module PageObject
22
18
  # will be matched with the text from the columns in the first row.
23
19
  # The text can be a substring of the full column text.
24
20
  #
25
- def [](idx)
26
- idx = find_index_by_title(idx) if idx.kind_of?(String)
27
- return nil unless idx && columns >= idx + 1
28
- initialize_cell(element[idx])
21
+ def [](what)
22
+ idx = find_index(what)
23
+ idx && cell_items[idx]
29
24
  end
30
25
 
31
26
  #
32
27
  # Returns the number of columns in the table.
33
28
  #
34
29
  def columns
35
- element.wd.find_elements(:xpath, child_xpath).size
30
+ cell_items.size
36
31
  end
37
32
 
38
33
  protected
39
34
 
40
- def child_xpath
41
- ".//child::td|th"
35
+ def cell_items
36
+ @cell_items ||= element.cells.map do |obj|
37
+ ::PageObject::Elements::TableCell.new(obj)
38
+ end
42
39
  end
43
40
 
44
- def initialize_cell(row_element)
45
- ::PageObject::Elements::TableCell.new(row_element)
46
- end
41
+ def find_index(what)
42
+ return what if what.is_a? Integer
47
43
 
48
- def find_index_by_title(title)
49
- table = element.parent
50
- table = table.parent if table.tag_name == 'tbody'
51
- if table.instance_of? Watir::HTMLElement
52
- table = table.to_subtype
44
+ parent(tag_name: 'table').headers.find_index do |header|
45
+ header.text.include? what
53
46
  end
54
- first_row = table[0]
55
- first_row.cells.find_index {|column| column.text.include? title }
56
47
  end
57
-
58
48
  end
59
49
 
60
50
  ::PageObject::Elements.tag_to_class[:tr] = ::PageObject::Elements::TableRow
@@ -1,18 +1,9 @@
1
-
2
1
  module PageObject
3
2
  module Elements
4
3
  class TextArea < Element
5
4
 
6
- #
7
- # Set the value of the TextArea
8
- #
9
- def value=(new_value)
10
- element.set(new_value)
11
- end
12
-
13
5
  end
14
6
 
15
7
  ::PageObject::Elements.tag_to_class[:textarea] = ::PageObject::Elements::TextArea
16
-
17
8
  end
18
9
  end
@@ -1,15 +1,7 @@
1
-
2
1
  module PageObject
3
2
  module Elements
4
3
  class TextField < Element
5
4
 
6
- #
7
- # Set the value of the TextField
8
- #
9
- def value=(new_value)
10
- element.set(new_value)
11
- end
12
-
13
5
  end
14
6
 
15
7
  ::PageObject::Elements.type_to_class[:text] = ::PageObject::Elements::TextField
@@ -1,4 +1,3 @@
1
-
2
1
  module PageObject
3
2
  module Elements
4
3
  class UnorderedList < Element
@@ -9,10 +8,8 @@ module PageObject
9
8
  #
10
9
  # @return [PageObject::Elements::ListItem]
11
10
  #
12
- def each
13
- for index in 1..self.items do
14
- yield self[index-1]
15
- end
11
+ def each(&block)
12
+ list_items.each(&block)
16
13
  end
17
14
 
18
15
  #
@@ -22,39 +19,26 @@ module PageObject
22
19
  # @return [PageObject::Elements::ListItem]
23
20
  #
24
21
  def [](idx)
25
- Object::PageObject::Elements::ListItem.new(children[idx])
22
+ list_items[idx]
26
23
  end
27
24
 
28
25
  #
29
26
  # Return the number of items contained in the unordered list
30
27
  #
31
28
  def items
32
- children.size
29
+ list_items.size
33
30
  end
34
31
 
35
32
  #
36
- # Return the ListItem objects that are children of the
37
- # UnorderedList
33
+ # Return Array of ListItem objects that are children of the UnorderedList
38
34
  #
39
35
  def list_items
40
- children.collect do |obj|
36
+ @list_items ||= children(tag_name: 'li').map do |obj|
41
37
  Object::PageObject::Elements::ListItem.new(obj)
42
38
  end
43
39
  end
44
-
45
- protected
46
-
47
- def child_xpath
48
- "./child::li"
49
- end
50
-
51
- def children
52
- element.uls(:xpath => child_xpath)
53
- end
54
-
55
40
  end
56
41
 
57
42
  ::PageObject::Elements.tag_to_class[:ul] = ::PageObject::Elements::UnorderedList
58
-
59
43
  end
60
44
  end
@@ -3,6 +3,7 @@ module PageObject
3
3
  class Video < Media
4
4
 
5
5
  end
6
+
6
7
  ::PageObject::Elements.type_to_class[:video] = ::PageObject::Elements::Video
7
8
  end
8
9
  end
@@ -8,7 +8,7 @@ module PageObject
8
8
  # matching the Hash key to the name you provided when declaring
9
9
  # the element on your page.
10
10
  #
11
- # Checkboxe and Radio Button values must be true or false.
11
+ # Checkbox and Radio Button values must be true or false.
12
12
  #
13
13
  # @example
14
14
  # class ExamplePage
@@ -24,7 +24,7 @@ module PageObject
24
24
  # example_page = ExamplePage.new(@browser)
25
25
  # example_page.populate_page_with :username => 'a name', :active => true
26
26
  #
27
- # @param [Hash] the data to use to populate this page. The key
27
+ # @param data [Hash] the data to use to populate this page. The key
28
28
  # can be either a string or a symbol. The value must be a string
29
29
  # for TextField, TextArea, SelectList, and FileField and must be true or
30
30
  # false for a Checkbox or RadioButton.
@@ -58,13 +58,10 @@ module PageObject
58
58
  return self.send("select_#{key}", value)
59
59
  end
60
60
 
61
- def populate_select_list(key, value)
61
+ def populate_select_list(key, value)
62
62
  select_element = self.send("#{key}_element")
63
- if select_element.options.include?(value)
64
- select_element.select(value)
65
- else
66
- select_element.select_value(value)
67
- end
63
+ return select_element.select(value) if select_element.include?(value)
64
+ select_element.select_value(value)
68
65
  end
69
66
 
70
67
  def is_text?(key)
@@ -34,8 +34,8 @@ module PageObject
34
34
  end
35
35
 
36
36
  def self.selenium_browser(root)
37
- return Watir::Browser.new(root) if root.is_a?(::Selenium::WebDriver::Driver)
38
- Watir::Browser.new(Selenium::WebDriver::Driver.new(root.send(:bridge)))
37
+ return ::Watir::Browser.new(root) if root.is_a?(::Selenium::WebDriver::Driver)
38
+ ::Watir::Browser.new(Selenium::WebDriver::Driver.new(root.send(:bridge)))
39
39
  end
40
40
 
41
41
  def self.watir?(browser)
@@ -1,5 +1,4 @@
1
1
  require 'page-object/elements'
2
- require 'page-object/core_ext/string'
3
2
 
4
3
 
5
4
  module PageObject
@@ -1083,7 +1082,7 @@ module PageObject
1083
1082
  identifier = frame.values.first.map do |key, value|
1084
1083
  if value.is_a?(Regexp)
1085
1084
  ":#{key} => #{value.inspect}"
1086
- elsif value.to_s.is_integer
1085
+ elsif value.is_a? Integer
1087
1086
  ":#{key} => #{value}"
1088
1087
  else
1089
1088
  ":#{key} => '#{value}'"
@@ -1,4 +1,4 @@
1
1
  module PageObject
2
2
  # @private
3
- VERSION = "2.2"
3
+ VERSION = "2.2.1"
4
4
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(pkg|spec|features|coverage)/}) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_dependency 'watir', '~> 6.0'
20
+ s.add_dependency 'watir', '~> 6.7'
21
21
  s.add_dependency 'selenium-webdriver', '~> 3.0'
22
22
  s.add_dependency 'page_navigation', '>= 0.10'
23
23
 
@@ -27,5 +27,6 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency 'rack', '~> 1.0'
28
28
  s.add_development_dependency 'coveralls', '~> 0.8.1'
29
29
  s.add_development_dependency 'net-http-persistent'
30
+ s.add_development_dependency 'webdrivers', '~> 3.1'
30
31
 
31
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page-object
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.2'
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Morgan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-08-04 00:00:00.000000000 Z
12
+ date: 2017-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '6.0'
20
+ version: '6.7'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '6.0'
27
+ version: '6.7'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: selenium-webdriver
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +137,20 @@ dependencies:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: webdrivers
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '3.1'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '3.1'
140
154
  description: Page Object DSL that works with both Watir and Selenium
141
155
  email:
142
156
  - jeff.morgan@leandog.com
@@ -160,7 +174,6 @@ files:
160
174
  - cucumber.yml
161
175
  - lib/page-object.rb
162
176
  - lib/page-object/accessors.rb
163
- - lib/page-object/core_ext/string.rb
164
177
  - lib/page-object/element_locators.rb
165
178
  - lib/page-object/elements.rb
166
179
  - lib/page-object/elements/area.rb
@@ -1,5 +0,0 @@
1
- class String
2
- def is_integer
3
- true if Integer(self) rescue false
4
- end
5
- end