page-object 2.0.0 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -2
  3. data/ChangeLog +10 -0
  4. data/README.md +12 -0
  5. data/Rakefile +2 -12
  6. data/cucumber.yml +2 -4
  7. data/lib/page-object.rb +12 -20
  8. data/lib/page-object/accessors.rb +50 -363
  9. data/lib/page-object/elements/bold.rb +0 -1
  10. data/lib/page-object/elements/button.rb +0 -4
  11. data/lib/page-object/elements/check_box.rb +19 -7
  12. data/lib/page-object/elements/div.rb +0 -4
  13. data/lib/page-object/elements/element.rb +159 -90
  14. data/lib/page-object/elements/file_field.rb +5 -7
  15. data/lib/page-object/elements/form.rb +0 -8
  16. data/lib/page-object/elements/hidden_field.rb +1 -4
  17. data/lib/page-object/elements/image.rb +13 -7
  18. data/lib/page-object/elements/label.rb +0 -4
  19. data/lib/page-object/elements/link.rb +0 -13
  20. data/lib/page-object/elements/list_item.rb +0 -3
  21. data/lib/page-object/elements/ordered_list.rb +30 -5
  22. data/lib/page-object/elements/radio_button.rb +12 -7
  23. data/lib/page-object/elements/select_list.rb +40 -8
  24. data/lib/page-object/elements/span.rb +0 -3
  25. data/lib/page-object/elements/table.rb +26 -5
  26. data/lib/page-object/elements/table_cell.rb +0 -4
  27. data/lib/page-object/elements/table_row.rb +30 -5
  28. data/lib/page-object/elements/text_area.rb +7 -7
  29. data/lib/page-object/elements/text_field.rb +5 -11
  30. data/lib/page-object/elements/unordered_list.rb +30 -5
  31. data/lib/page-object/indexed_properties.rb +1 -0
  32. data/lib/page-object/platforms.rb +0 -1
  33. data/lib/page-object/platforms/watir.rb +26 -4
  34. data/lib/page-object/platforms/watir/page_object.rb +4 -4
  35. data/lib/page-object/version.rb +1 -1
  36. data/lib/page-object/widgets.rb +0 -1
  37. data/page-object.gemspec +1 -15
  38. metadata +5 -47
  39. data/lib/page-object/platforms/selenium_webdriver.rb +0 -30
  40. data/lib/page-object/platforms/selenium_webdriver/button.rb +0 -15
  41. data/lib/page-object/platforms/selenium_webdriver/check_box.rb +0 -29
  42. data/lib/page-object/platforms/selenium_webdriver/element.rb +0 -335
  43. data/lib/page-object/platforms/selenium_webdriver/file_field.rb +0 -16
  44. data/lib/page-object/platforms/selenium_webdriver/form.rb +0 -16
  45. data/lib/page-object/platforms/selenium_webdriver/image.rb +0 -28
  46. data/lib/page-object/platforms/selenium_webdriver/link.rb +0 -23
  47. data/lib/page-object/platforms/selenium_webdriver/ordered_list.rb +0 -41
  48. data/lib/page-object/platforms/selenium_webdriver/page_object.rb +0 -1297
  49. data/lib/page-object/platforms/selenium_webdriver/radio_button.rb +0 -22
  50. data/lib/page-object/platforms/selenium_webdriver/select_list.rb +0 -93
  51. data/lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb +0 -42
  52. data/lib/page-object/platforms/selenium_webdriver/table.rb +0 -42
  53. data/lib/page-object/platforms/selenium_webdriver/table_row.rb +0 -43
  54. data/lib/page-object/platforms/selenium_webdriver/text_area.rb +0 -17
  55. data/lib/page-object/platforms/selenium_webdriver/text_field.rb +0 -17
  56. data/lib/page-object/platforms/selenium_webdriver/unordered_list.rb +0 -37
  57. data/lib/page-object/platforms/watir/check_box.rb +0 -29
  58. data/lib/page-object/platforms/watir/element.rb +0 -295
  59. data/lib/page-object/platforms/watir/file_field.rb +0 -16
  60. data/lib/page-object/platforms/watir/form.rb +0 -16
  61. data/lib/page-object/platforms/watir/image.rb +0 -22
  62. data/lib/page-object/platforms/watir/link.rb +0 -15
  63. data/lib/page-object/platforms/watir/ordered_list.rb +0 -40
  64. data/lib/page-object/platforms/watir/radio_button.rb +0 -22
  65. data/lib/page-object/platforms/watir/select_list.rb +0 -74
  66. data/lib/page-object/platforms/watir/table.rb +0 -38
  67. data/lib/page-object/platforms/watir/table_row.rb +0 -37
  68. data/lib/page-object/platforms/watir/text_area.rb +0 -23
  69. data/lib/page-object/platforms/watir/text_field.rb +0 -16
  70. data/lib/page-object/platforms/watir/unordered_list.rb +0 -42
@@ -20,6 +20,7 @@ module PageObject
20
20
  name = identifier[1]
21
21
  how_and_what = identifier[2].clone # Cannot modify the original...
22
22
  how_and_what.each do |key, value|
23
+ next if value.is_a? Regexp # Cannot format Regexp with %
23
24
  if key == :index
24
25
  how_and_what[key] = (value % index).to_i
25
26
  else
@@ -14,5 +14,4 @@ module PageObject
14
14
  end
15
15
  end
16
16
  require 'page-object/platforms/watir'
17
- require 'page-object/platforms/selenium_webdriver'
18
17
 
@@ -3,26 +3,48 @@ module PageObject
3
3
  module WatirWebDriver
4
4
 
5
5
  def self.create_page_object(browser)
6
+ browser = selenium_browser(browser) unless watir?(browser)
6
7
  return WatirWebDriver::PageObject.new(browser)
7
8
  end
8
9
 
9
10
  def self.is_for?(browser)
10
11
  require 'watir'
11
- browser.is_a?(::Watir::Browser) || browser.is_a?(::Watir::HTMLElement)
12
+ watir?(browser) || selenium?(browser)
12
13
  end
13
14
 
14
15
  def self.browser_for root
15
- return root if root.is_a?(::Watir::Browser)
16
- root.browser
16
+ return watir_browser(root) if watir?(root)
17
+ return selenium_browser(root) if selenium?(root)
18
+ nil
17
19
  end
18
20
 
19
21
  def self.root_element_for root
20
- Elements::Element.new root, :platform => :watir if root.is_a? ::Watir::HTMLElement
22
+ Elements::Element.new root, :platform => :watir if is_for? root
21
23
  end
22
24
 
23
25
  def self.browser_root_for browser
24
26
  browser.element
25
27
  end
28
+
29
+ private
30
+
31
+ def self.watir_browser(root)
32
+ return root if root.is_a?(::Watir::Browser)
33
+ root.browser
34
+ end
35
+
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)))
39
+ end
40
+
41
+ def self.watir?(browser)
42
+ browser.is_a?(::Watir::Browser) || browser.is_a?(::Watir::HTMLElement)
43
+ end
44
+
45
+ def self.selenium?(browser)
46
+ browser.is_a?(::Selenium::WebDriver::Driver) || browser.is_a?(::Selenium::WebDriver::Element)
47
+ end
26
48
  end
27
49
  end
28
50
  end
@@ -17,8 +17,8 @@ module PageObject
17
17
  PLATFORM_NAME = :watir
18
18
 
19
19
  def self.define_widget_accessors(widget_tag, widget_class, base_element_tag)
20
- define_widget_singular_accessor(base_element_tag, widget_class, widget_tag)
21
- define_widget_multiple_accessor(base_element_tag, widget_class, widget_tag)
20
+ define_widget_singular_accessor(base_element_tag, widget_class, widget_tag)
21
+ define_widget_multiple_accessor(base_element_tag, widget_class, widget_tag)
22
22
  end
23
23
 
24
24
  def initialize(browser)
@@ -232,7 +232,7 @@ module PageObject
232
232
  #
233
233
  def text_fields_for(identifier)
234
234
  elements = find_watir_elements("text_fields(identifier)", Elements::TextField, identifier)
235
- elements.select {|e| e.element.tag_name == 'input'}
235
+ elements.select { |e| e.element.tag_name == 'input' }
236
236
  end
237
237
 
238
238
  #
@@ -646,7 +646,7 @@ module PageObject
646
646
  find_watir_elements("uls(identifier)", Elements::UnorderedList, identifier, 'ul')
647
647
  end
648
648
 
649
- #
649
+ #
650
650
  # platform method to retrieve the text from an ordered list
651
651
  # See PageObject::Accessors#ordered_list
652
652
  #
@@ -1,4 +1,4 @@
1
1
  module PageObject
2
2
  # @private
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1"
4
4
  end
@@ -1,5 +1,4 @@
1
1
  require 'page-object/elements'
2
- require 'page-object/platforms/selenium_webdriver/page_object'
3
2
  require 'page-object/platforms/watir/page_object'
4
3
 
5
4
  module PageObject
@@ -2,18 +2,6 @@
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
  require "page-object/version"
4
4
 
5
- message =
6
- """
7
- This version of the gem moves to using the new Watir gem and away from
8
- using Watir Webdriver. You will need to update you Gemfile to use `watir`
9
- instead of `watir-webdriver` and update any `require` statements in your
10
- code.
11
-
12
- This is an important move as Watir Webdriver will not be supported any
13
- longer. All new development has been moved to Watir. There are also
14
- significant benefits to this move. See the Watir site at
15
- https://watir.github.io for more details.
16
- """
17
5
 
18
6
  Gem::Specification.new do |s|
19
7
  s.name = "page-object"
@@ -29,12 +17,10 @@ Gem::Specification.new do |s|
29
17
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(pkg|spec|features|coverage)/}) }
30
18
  s.require_paths = ["lib"]
31
19
 
32
- s.post_install_message = message
33
-
34
20
  s.add_dependency 'watir', '~> 6.0'
35
21
  s.add_dependency 'selenium-webdriver', '~> 3.0'
36
22
  s.add_dependency 'page_navigation', '>= 0.9'
37
- s.add_dependency 'net-http-persistent', '~> 2.9.4'
23
+ s.add_dependency 'net-http-persistent', '~> 3.0'
38
24
 
39
25
  s.add_development_dependency 'rspec', '>= 3.0.0'
40
26
  s.add_development_dependency 'cucumber', '>= 2.0.0'
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.0.0
4
+ version: '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: 2016-11-23 00:00:00.000000000 Z
12
+ date: 2017-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 2.9.4
62
+ version: '3.0'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: 2.9.4
69
+ version: '3.0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -206,40 +206,8 @@ files:
206
206
  - lib/page-object/page_factory.rb
207
207
  - lib/page-object/page_populator.rb
208
208
  - lib/page-object/platforms.rb
209
- - lib/page-object/platforms/selenium_webdriver.rb
210
- - lib/page-object/platforms/selenium_webdriver/button.rb
211
- - lib/page-object/platforms/selenium_webdriver/check_box.rb
212
- - lib/page-object/platforms/selenium_webdriver/element.rb
213
- - lib/page-object/platforms/selenium_webdriver/file_field.rb
214
- - lib/page-object/platforms/selenium_webdriver/form.rb
215
- - lib/page-object/platforms/selenium_webdriver/image.rb
216
- - lib/page-object/platforms/selenium_webdriver/link.rb
217
- - lib/page-object/platforms/selenium_webdriver/ordered_list.rb
218
- - lib/page-object/platforms/selenium_webdriver/page_object.rb
219
- - lib/page-object/platforms/selenium_webdriver/radio_button.rb
220
- - lib/page-object/platforms/selenium_webdriver/select_list.rb
221
- - lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb
222
- - lib/page-object/platforms/selenium_webdriver/table.rb
223
- - lib/page-object/platforms/selenium_webdriver/table_row.rb
224
- - lib/page-object/platforms/selenium_webdriver/text_area.rb
225
- - lib/page-object/platforms/selenium_webdriver/text_field.rb
226
- - lib/page-object/platforms/selenium_webdriver/unordered_list.rb
227
209
  - lib/page-object/platforms/watir.rb
228
- - lib/page-object/platforms/watir/check_box.rb
229
- - lib/page-object/platforms/watir/element.rb
230
- - lib/page-object/platforms/watir/file_field.rb
231
- - lib/page-object/platforms/watir/form.rb
232
- - lib/page-object/platforms/watir/image.rb
233
- - lib/page-object/platforms/watir/link.rb
234
- - lib/page-object/platforms/watir/ordered_list.rb
235
210
  - lib/page-object/platforms/watir/page_object.rb
236
- - lib/page-object/platforms/watir/radio_button.rb
237
- - lib/page-object/platforms/watir/select_list.rb
238
- - lib/page-object/platforms/watir/table.rb
239
- - lib/page-object/platforms/watir/table_row.rb
240
- - lib/page-object/platforms/watir/text_area.rb
241
- - lib/page-object/platforms/watir/text_field.rb
242
- - lib/page-object/platforms/watir/unordered_list.rb
243
211
  - lib/page-object/section_collection.rb
244
212
  - lib/page-object/version.rb
245
213
  - lib/page-object/widgets.rb
@@ -249,17 +217,7 @@ homepage: http://github.com/cheezy/page-object
249
217
  licenses:
250
218
  - MIT
251
219
  metadata: {}
252
- post_install_message: |2
253
-
254
- This version of the gem moves to using the new Watir gem and away from
255
- using Watir Webdriver. You will need to update you Gemfile to use `watir`
256
- instead of `watir-webdriver` and update any `require` statements in your
257
- code.
258
-
259
- This is an important move as Watir Webdriver will not be supported any
260
- longer. All new development has been moved to Watir. There are also
261
- significant benefits to this move. See the Watir site at
262
- https://watir.github.io for more details.
220
+ post_install_message:
263
221
  rdoc_options: []
264
222
  require_paths:
265
223
  - lib
@@ -1,30 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module SeleniumWebDriver
4
-
5
- def self.create_page_object(browser)
6
- SeleniumWebDriver::PageObject.new(browser)
7
- end
8
-
9
- def self.is_for?(browser)
10
- require 'selenium-webdriver'
11
- browser.is_a?(::Selenium::WebDriver::Driver) || browser.is_a?(::Selenium::WebDriver::Element)
12
- end
13
-
14
- def self.browser_for root
15
- return root if root.is_a?(::Selenium::WebDriver::Driver)
16
- Selenium::WebDriver::Driver.new(root.send(:bridge))
17
- end
18
-
19
- def self.root_element_for root
20
- Elements::Element.new root, platform: :selenium_webdriver if root.is_a?(::Selenium::WebDriver::Element)
21
- end
22
-
23
- def self.browser_root_for browser
24
- browser.find_element(tag_name: 'html')
25
- end
26
- end
27
- end
28
- end
29
-
30
- PageObject::Platforms.register(:selenium_webdriver, PageObject::Platforms::SeleniumWebDriver)
@@ -1,15 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module SeleniumWebDriver
4
- module Button
5
- #
6
- # Override PageObject::PLatforms::SeleniumElement#text
7
- # to get #text from buttons and #attribute('value') from inputs
8
- #
9
- def text
10
- element.tag_name == 'button' ? element.text : element.attribute('value')
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,29 +0,0 @@
1
- module PageObject
2
- module Platforms
3
- module SeleniumWebDriver
4
- module CheckBox
5
-
6
- #
7
- # check the checkbox
8
- #
9
- def check
10
- element.click unless element.selected?
11
- end
12
-
13
- #
14
- # uncheck the checkbox
15
- #
16
- def uncheck
17
- element.click if element.selected?
18
- end
19
-
20
- #
21
- # return true if it is checked
22
- #
23
- def checked?
24
- element.selected?
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,335 +0,0 @@
1
- require 'watir/atoms'
2
-
3
- module PageObject
4
- module Platforms
5
- #
6
- # Selenium implementation of the common functionality found across all elements
7
- #
8
- module SeleniumWebDriver
9
- module Element
10
- include Watir::Atoms
11
-
12
- #
13
- # return true if an element is visible
14
- #
15
- def visible?
16
- element.displayed?
17
- end
18
-
19
- #
20
- # return true if an element exists
21
- #
22
- def exists?
23
- not element.nil?
24
- end
25
-
26
- #
27
- # flash the element by temporarily changing the background color
28
- #
29
- def flash
30
- original_color = attribute('backgroundColor')
31
- the_bridge = bridge
32
- 10.times do |n|
33
- color = (n % 2 == 0) ? 'red' : original_color
34
- the_bridge.execute_script("arguments[0].style.backgroundColor = '#{color}'", element)
35
- end
36
- end
37
-
38
- #
39
- # Get the text for the element
40
- #
41
- # @return [String]
42
- #
43
- def text
44
- element.text
45
- end
46
-
47
- #
48
- # Get the html for the element
49
- #
50
- # @return [String]
51
- #
52
- def html
53
- script = "return (%s).apply(null, arguments)" % ATOMS.fetch(:getOuterHtml)
54
- bridge.execute_script(script, element).strip
55
- end
56
-
57
- #
58
- # Get the value of this element
59
- #
60
- # @return [String]
61
- #
62
- def value
63
- element.attribute('value')
64
- end
65
-
66
- #
67
- # compare this element to another to determine if they are equal
68
- #
69
- def ==(other)
70
- other.is_a? self.class and element == other.element
71
- end
72
-
73
- #
74
- # Get the tag name of this element
75
- #
76
- # @return [String]
77
- #
78
- def tag_name
79
- element.tag_name
80
- end
81
-
82
- #
83
- # Get the value of a the given attribute of the element. Will
84
- # return the current value, even if this has been modified
85
- # after the page has been loaded. More exactly, this method
86
- # will return the value of the given attribute, unless that
87
- # attribute is not present, in which case the value of the
88
- # property with the same name is returned. If neither value is
89
- # set, nil is returned. The "style" attribute is converted as
90
- # best can be to a text representation with a trailing
91
- # semi-colon. The following are deemed to be "boolean"
92
- # attributes, and will return either "true" or "false":
93
- #
94
- # async, autofocus, autoplay, checked, compact, complete,
95
- # controls, declare, defaultchecked, defaultselected, defer,
96
- # disabled, draggable, ended, formnovalidate, hidden, indeterminate,
97
- # iscontenteditable, ismap, itemscope, loop, multiple, muted,
98
- # nohref, noresize, noshade, novalidate, nowrap, open, paused,
99
- # pubdate, readonly, required, reversed, scoped, seamless, seeking,
100
- # selected, spellcheck, truespeed, willvalidate
101
- #
102
- # Finally, the following commonly mis-capitalized
103
- # attribute/property names are evaluated as expected:
104
- #
105
- # class, readonly
106
- #
107
- # @param [String]
108
- # attribute name
109
- # @return [String,nil]
110
- # attribute value
111
- #
112
- def attribute(attribute_name)
113
- element.attribute attribute_name
114
- end
115
-
116
- #
117
- # Fire the provided event on the current element
118
- #
119
- def fire_event(event_name)
120
- event_name = event_name.to_s.sub(/^on/, '').downcase
121
- script = "return (%s).apply(null, arguments)" % ATOMS.fetch(:fireEvent)
122
- bridge.execute_script(script, element, event_name)
123
- end
124
-
125
- #
126
- # hover over the element
127
- #
128
- def hover
129
- mouse = Selenium::WebDriver::Mouse.new(bridge)
130
- mouse.move_to(element)
131
- end
132
-
133
- #
134
- # hover over the element
135
- #
136
- def double_click
137
- mouse = Selenium::WebDriver::Mouse.new(bridge)
138
- mouse.double_click(element)
139
- end
140
-
141
- #
142
- # find the parent element
143
- #
144
- def parent
145
- script = "return (%s).apply(null, arguments)" % ATOMS.fetch(:getParentElement)
146
- parent = bridge.execute_script(script, element)
147
- type = element.attribute(:type).to_s.downcase if parent.tag_name.to_sym == :input
148
- cls = ::PageObject::Elements.element_class_for(parent.tag_name, type)
149
- cls.new(parent, :platform => @platform.class::PLATFORM_NAME)
150
- end
151
-
152
- #
153
- # Set the focus to the current element
154
- #
155
- def focus
156
- bridge.execute_script("return arguments[0].focus()", element)
157
- end
158
-
159
- #
160
- # return true if an element is focused
161
- #
162
- def focused?
163
- element == bridge.active_element
164
- end
165
-
166
- #
167
- # Select the provided text
168
- #
169
- def select_text(text)
170
- Watir::Atoms.load(:selectText)
171
- script = "return (%s).apply(null, arguments)" % ATOMS.fetch(:selectText)
172
- bridge.execute_script(script, element, text)
173
- end
174
-
175
- #
176
- # Click this element
177
- #
178
- def right_click
179
- element.context_click
180
- end
181
-
182
- #
183
- # Waits until the element is present
184
- #
185
- # @param [Integer] (defaults to: 5) seconds to wait before timing out
186
- #
187
- def when_present(timeout=::PageObject.default_element_wait)
188
- wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element not present in #{timeout} seconds"})
189
- wait.until do
190
- self.exists?
191
- end
192
- self
193
- end
194
-
195
- #
196
- # Waits until the element is not present
197
- #
198
- # @param [Integer] (defaults to: 5) seconds to wait before
199
- # timing out
200
- #
201
- def when_not_present(timeout=::PageObject.default_element_wait)
202
- wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element still present in #{timeout} seconds"})
203
- wait.until do
204
- not_present = false
205
- begin
206
- not_present = false if element and element.displayed?
207
- rescue Selenium::WebDriver::Error::ObsoleteElementError
208
- not_present = true
209
- end
210
- not_present
211
- end
212
- end
213
-
214
- #
215
- # Waits until the element is visible
216
- #
217
- # @param [Integer] (defaults to: 5) seconds to wait before timing out
218
- #
219
- def when_visible(timeout=::PageObject.default_element_wait)
220
- wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element not visible in #{timeout} seconds"})
221
- wait.until do
222
- self.visible?
223
- end
224
- self
225
- end
226
-
227
- #
228
- # Waits until the element is not visible
229
- #
230
- # @param [Integer] (defaults to: 5) seconds to wait before timing out
231
- #
232
- def when_not_visible(timeout=::PageObject.default_element_wait)
233
- wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element still visible in #{timeout} seconds"})
234
- wait.until do
235
- not self.visible?
236
- end
237
- self
238
- end
239
-
240
- #
241
- # Waits until the block returns true
242
- #
243
- # @param [Integer] (defaults to: 5) seconds to wait before timing out
244
- # @param [String] the message to display if the event timeouts
245
- # @param the block to execute when the event occurs
246
- #
247
- def wait_until(timeout=::PageObject.default_element_wait, message=nil, &block)
248
- wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => message})
249
- wait.until &block
250
- end
251
-
252
- #
253
- # Send keystrokes to this element
254
- #
255
- # @param [String, Symbol, Array]
256
- #
257
- # Examples:
258
- #
259
- # element.send_keys "foo" #=> value: 'foo'
260
- # element.send_keys "tet", :arrow_left, "s" #=> value: 'test'
261
- # element.send_keys [:control, 'a'], :space #=> value: ' '
262
- #
263
- # @see Selenium::WebDriver::Keys::KEYS
264
- #
265
- def send_keys(*args)
266
- element.send_keys(*args)
267
- end
268
-
269
- #
270
- # clear the contents of the element
271
- #
272
- def clear
273
- element.clear
274
- end
275
-
276
- #
277
- # get the id of the element
278
- #
279
- def id
280
- attribute(:id)
281
- end
282
-
283
- #
284
- # Scroll until the element is viewable
285
- #
286
- def scroll_into_view
287
- element.location_once_scrolled_into_view
288
- end
289
-
290
- #
291
- # location of element (x, y)
292
- #
293
- def location
294
- element.location
295
- end
296
-
297
- #
298
- # size of element (width, height)
299
- #
300
- def size
301
- element.size
302
- end
303
-
304
- #
305
- # Get height of element
306
- #
307
- def height
308
- element.size['height']
309
- end
310
-
311
- #
312
- # Get width of element
313
- #
314
- def width
315
- element.size['width']
316
- end
317
-
318
- #
319
- # Get centre coordinates of element
320
- #
321
- def centre
322
- location = element.location
323
- size = element.size
324
- {'y' => (location['y'] + (size['height']/2)), 'x' => (location['x'] + (size['width']/2))}
325
- end
326
-
327
- private
328
-
329
- def bridge
330
- element.instance_variable_get(:@bridge)
331
- end
332
- end
333
- end
334
- end
335
- end