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,7 +1,7 @@
1
1
  module PageObject
2
2
  module Elements
3
3
  class ListItem < Element
4
-
4
+
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module PageObject
2
2
  module Elements
3
3
  class Option < Element
4
-
4
+
5
5
  end
6
6
  end
7
7
  end
@@ -2,12 +2,12 @@ module PageObject
2
2
  module Elements
3
3
  class OrderedList < Element
4
4
  include Enumerable
5
-
5
+
6
6
  def initialize(element, platform)
7
7
  @element = element
8
8
  include_platform_for platform
9
9
  end
10
-
10
+
11
11
  #
12
12
  # iterator that yields with a PageObject::Elements::ListItem
13
13
  #
@@ -15,16 +15,16 @@ module PageObject
15
15
  #
16
16
  def each
17
17
  for index in 1..self.items do
18
- yield self[index-1]
18
+ yield self[index-1]
19
19
  end
20
- end
21
-
20
+ end
21
+
22
22
  protected
23
-
23
+
24
24
  def child_xpath
25
25
  ".//child::li"
26
26
  end
27
-
27
+
28
28
  def self.watir_finders
29
29
  [:class, :id, :index, :xpath]
30
30
  end
@@ -32,16 +32,16 @@ module PageObject
32
32
  def include_platform_for platform
33
33
  super
34
34
  if platform[:platform] == :watir
35
- require 'page-object/platforms/watir_ordered_list'
36
- self.class.send :include, PageObject::Platforms::WatirOrderedList
35
+ require 'page-object/platforms/watir/ordered_list'
36
+ self.class.send :include, PageObject::Platforms::Watir::OrderedList
37
37
  elsif platform[:platform] == :selenium
38
- require 'page-object/platforms/selenium_ordered_list'
39
- self.class.send :include, PageObject::Platforms::SeleniumOrderedList
38
+ require 'page-object/platforms/selenium/ordered_list'
39
+ self.class.send :include, PageObject::Platforms::Selenium::OrderedList
40
40
  else
41
- raise ArgumentError, "expect platform to be :watir or :selenium"
41
+ raise ArgumentError, "expect platform to be :watir or :selenium"
42
42
  end
43
43
  end
44
-
44
+
45
45
  end
46
46
  end
47
47
  end
@@ -12,7 +12,7 @@ module PageObject
12
12
  def child_xpath
13
13
  ".//child::option"
14
14
  end
15
-
15
+
16
16
  def self.watir_finders
17
17
  super + [:text, :value]
18
18
  end
@@ -20,13 +20,13 @@ module PageObject
20
20
  def include_platform_for platform
21
21
  super
22
22
  if platform[:platform] == :watir
23
- require 'page-object/platforms/watir_select_list'
24
- self.class.send :include, PageObject::Platforms::WatirSelectList
23
+ require 'page-object/platforms/watir/select_list'
24
+ self.class.send :include, PageObject::Platforms::Watir::SelectList
25
25
  elsif platform[:platform] == :selenium
26
- require 'page-object/platforms/selenium_select_list'
27
- self.class.send :include, PageObject::Platforms::SeleniumSelectList
26
+ require 'page-object/platforms/selenium/select_list'
27
+ self.class.send :include, PageObject::Platforms::Selenium::SelectList
28
28
  else
29
- raise ArgumentError, "expect platform to be :watir or :selenium"
29
+ raise ArgumentError, "expect platform to be :watir or :selenium"
30
30
  end
31
31
  end
32
32
 
@@ -1,9 +1,9 @@
1
1
  module PageObject
2
2
  module Elements
3
3
  class Span < Element
4
-
4
+
5
5
  protected
6
-
6
+
7
7
  def self.watir_finders
8
8
  [:class, :id, :index, :xpath]
9
9
  end
@@ -2,12 +2,12 @@ module PageObject
2
2
  module Elements
3
3
  class Table < Element
4
4
  include Enumerable
5
-
5
+
6
6
  def initialize(element, platform)
7
7
  @element = element
8
8
  include_platform_for platform
9
9
  end
10
-
10
+
11
11
  #
12
12
  # iterator that yields with a PageObject::Elements::TableRow
13
13
  #
@@ -15,26 +15,26 @@ module PageObject
15
15
  #
16
16
  def each
17
17
  for index in 1..self.rows do
18
- yield self[index-1]
18
+ yield self[index-1]
19
19
  end
20
20
  end
21
-
21
+
22
22
  protected
23
-
23
+
24
24
  def child_xpath
25
25
  ".//child::tr"
26
26
  end
27
-
27
+
28
28
  def include_platform_for platform
29
29
  super
30
30
  if platform[:platform] == :watir
31
- require 'page-object/platforms/watir_table'
32
- self.class.send :include, PageObject::Platforms::WatirTable
31
+ require 'page-object/platforms/watir/table'
32
+ self.class.send :include, PageObject::Platforms::Watir::Table
33
33
  elsif platform[:platform] == :selenium
34
- require 'page-object/platforms/selenium_table'
35
- self.class.send :include, PageObject::Platforms::SeleniumTable
34
+ require 'page-object/platforms/selenium/table'
35
+ self.class.send :include, PageObject::Platforms::Selenium::Table
36
36
  else
37
- raise ArgumentError, "expect platform to be :watir or :selenium"
37
+ raise ArgumentError, "expect platform to be :watir or :selenium"
38
38
  end
39
39
  end
40
40
  end
@@ -7,7 +7,7 @@ module PageObject
7
7
  @element = element
8
8
  include_platform_for platform
9
9
  end
10
-
10
+
11
11
  #
12
12
  # iterator that yields with a PageObject::Elements::TableCell
13
13
  #
@@ -15,26 +15,26 @@ module PageObject
15
15
  #
16
16
  def each
17
17
  for index in 1..self.columns do
18
- yield self[index-1]
18
+ yield self[index-1]
19
19
  end
20
20
  end
21
21
 
22
22
  protected
23
-
23
+
24
24
  def child_xpath
25
25
  ".//child::td|th"
26
26
  end
27
-
27
+
28
28
  def include_platform_for platform
29
29
  super
30
30
  if platform[:platform] == :watir
31
- require 'page-object/platforms/watir_table_row'
32
- self.class.send :include, PageObject::Platforms::WatirTableRow
31
+ require 'page-object/platforms/watir/table_row'
32
+ self.class.send :include, PageObject::Platforms::Watir::TableRow
33
33
  elsif platform[:platform] == :selenium
34
- require 'page-object/platforms/selenium_table_row'
35
- self.class.send :include, PageObject::Platforms::SeleniumTableRow
34
+ require 'page-object/platforms/selenium/table_row'
35
+ self.class.send :include, PageObject::Platforms::Selenium::TableRow
36
36
  else
37
- raise ArgumentError, "expect platform to be :watir or :selenium"
37
+ raise ArgumentError, "expect platform to be :watir or :selenium"
38
38
  end
39
39
  end
40
40
  end
@@ -3,19 +3,19 @@ module PageObject
3
3
  class TextArea < Element
4
4
 
5
5
  protected
6
-
6
+
7
7
  def self.watir_finders
8
8
  super + [:tag_name]
9
9
  end
10
-
10
+
11
11
  def self.watir_mapping
12
12
  super.merge({:css => :tag_name})
13
13
  end
14
-
14
+
15
15
  def self.selenium_finders
16
16
  super + [:css]
17
17
  end
18
-
18
+
19
19
  def self.selenium_mapping
20
20
  super.merge({:tag_name => :css})
21
21
  end
@@ -3,19 +3,19 @@ module PageObject
3
3
  class TextField < Element
4
4
 
5
5
  protected
6
-
6
+
7
7
  def self.watir_finders
8
8
  super + [:tag_name]
9
9
  end
10
-
10
+
11
11
  def self.watir_mapping
12
12
  super.merge({:css => :tag_name})
13
13
  end
14
-
14
+
15
15
  def self.selenium_finders
16
16
  super + [:css]
17
17
  end
18
-
18
+
19
19
  def self.selenium_mapping
20
20
  super.merge({:tag_name => :css})
21
21
  end
@@ -2,12 +2,12 @@ module PageObject
2
2
  module Elements
3
3
  class UnorderedList < Element
4
4
  include Enumerable
5
-
5
+
6
6
  def initialize(element, platform)
7
7
  @element = element
8
8
  include_platform_for platform
9
9
  end
10
-
10
+
11
11
  #
12
12
  # iterator that yields with a PageObject::Elements::ListItem
13
13
  #
@@ -15,17 +15,17 @@ module PageObject
15
15
  #
16
16
  def each
17
17
  for index in 1..self.items do
18
- yield self[index-1]
18
+ yield self[index-1]
19
19
  end
20
20
  end
21
-
22
-
21
+
22
+
23
23
  protected
24
-
24
+
25
25
  def child_xpath
26
26
  ".//child::li"
27
27
  end
28
-
28
+
29
29
  def self.watir_finders
30
30
  [:class, :id, :index, :xpath]
31
31
  end
@@ -33,16 +33,16 @@ module PageObject
33
33
  def include_platform_for platform
34
34
  super
35
35
  if platform[:platform] == :watir
36
- require 'page-object/platforms/watir_unordered_list'
37
- self.class.send :include, PageObject::Platforms::WatirUnorderedList
36
+ require 'page-object/platforms/watir/unordered_list'
37
+ self.class.send :include, PageObject::Platforms::Watir::UnorderedList
38
38
  elsif platform[:platform] == :selenium
39
- require 'page-object/platforms/selenium_unordered_list'
40
- self.class.send :include, PageObject::Platforms::SeleniumUnorderedList
39
+ require 'page-object/platforms/selenium/unordered_list'
40
+ self.class.send :include, PageObject::Platforms::Selenium::UnorderedList
41
41
  else
42
- raise ArgumentError, "expect platform to be :watir or :selenium"
42
+ raise ArgumentError, "expect platform to be :watir or :selenium"
43
43
  end
44
44
  end
45
-
45
+
46
46
  end
47
47
  end
48
48
  end
@@ -0,0 +1,24 @@
1
+ module PageObject
2
+ #
3
+ # module which provides a function for determining
4
+ # which platform to provide to the page object
5
+ #
6
+ module LoadsPlatform
7
+ #
8
+ # Determines which platform the Page Object should use based upon browser
9
+ #
10
+ # @example
11
+ # platform = load_platform(watir_webdriver_browser, PageObject.Adapters.list).send(:new, watir_webdriver_browser)
12
+ #
13
+ # @param [Object] A browser driver that has a supported adapter
14
+ # @param [adapters] a list of adapters that are currently supported
15
+ # @returns [PageObject]
16
+ #
17
+ def load_platform(browser, adapters)
18
+ adapters.each_value { |adapter|
19
+ return adapter.create_page_object(browser) if adapter.is_for?(browser)
20
+ }
21
+ raise 'Unable to pick a platform for the provided browser'
22
+ end
23
+ end
24
+ end
@@ -19,7 +19,7 @@ module PageObject
19
19
  # end
20
20
  #
21
21
  module PageFactory
22
-
22
+
23
23
  #
24
24
  # Create and navigate to a page object. The navigation will only work if the
25
25
  # 'page_url' method was call on the page object.
@@ -31,7 +31,7 @@ module PageObject
31
31
  def visit_page(page_class, &block)
32
32
  on_page page_class, true, &block
33
33
  end
34
-
34
+
35
35
  #
36
36
  # Create a page object.
37
37
  #
@@ -45,6 +45,6 @@ module PageObject
45
45
  block.call page if block
46
46
  page
47
47
  end
48
-
48
+
49
49
  end
50
50
  end
@@ -0,0 +1,18 @@
1
+ require 'page-object/loads_platform'
2
+
3
+ module PageObject
4
+ module Platforms
5
+ @@adapters = {}
6
+
7
+ def self.get
8
+ @@adapters
9
+ end
10
+
11
+ def self.register(key, adapter)
12
+ @@adapters[key] = adapter
13
+ end
14
+ end
15
+ end
16
+ require 'page-object/platforms/watir'
17
+ require 'page-object/platforms/selenium'
18
+
@@ -0,0 +1,16 @@
1
+ module PageObject
2
+ module Platforms
3
+ module Selenium
4
+
5
+ def self.create_page_object(browser)
6
+ require 'page-object/platforms/selenium/page_object'
7
+ return Object::PageObject::Platforms::Selenium::PageObject.new(browser)
8
+ end
9
+
10
+ def self.is_for?(browser)
11
+ browser.is_a? Object::Selenium::WebDriver::Driver
12
+ end
13
+ end
14
+ end
15
+ end
16
+ PageObject::Platforms.register(:selenium, PageObject::Platforms::Selenium)
@@ -0,0 +1,15 @@
1
+ module PageObject
2
+ module Platforms
3
+ module Selenium
4
+ module Button
5
+ #
6
+ # Override PageObject::PLatforms::SeleniumElement#text because
7
+ # #text does not reliabably return a value in Selenium
8
+ #
9
+ def text
10
+ raise "text is not available on button element in Selenium"
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,168 @@
1
+ module PageObject
2
+ module Platforms
3
+ #
4
+ # Selenium implementation of the common functionality found across all elements
5
+ #
6
+ module Selenium
7
+ module Element
8
+
9
+ #
10
+ # return true if an element is visible
11
+ #
12
+ def visible?
13
+ @element.displayed?
14
+ end
15
+
16
+ #
17
+ # return true if an element exists
18
+ #
19
+ def exists?
20
+ nil != @element
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.attribute('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 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
+ wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element not present in #{timeout} seconds"})
100
+ wait.until do
101
+ self.exists?
102
+ end
103
+ end
104
+
105
+ #
106
+ # Waits until the element is visible
107
+ #
108
+ # @param [Integer] (defaults to: 5) seconds to wait before timing out
109
+ #
110
+ def when_visible(timeout=5)
111
+ wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element not present in #{timeout} seconds"})
112
+ wait.until do
113
+ self.visible?
114
+ end
115
+ end
116
+
117
+ #
118
+ # Waits until the element is not visible
119
+ #
120
+ # @param [Integer] (defaults to: 5) seconds to wait before timing out
121
+ #
122
+ def when_not_visible(timeout=5)
123
+ wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element not present in #{timeout} seconds"})
124
+ wait.until do
125
+ not self.visible?
126
+ end
127
+ end
128
+
129
+ #
130
+ # Waits until the block returns true
131
+ #
132
+ # @param [Integer] (defaults to: 5) seconds to wait before timing out
133
+ # @param [String] the message to display if the event timeouts
134
+ # @param the block to execute when the event occurrs
135
+ #
136
+ def wait_until(timeout=5, message=nil, &block)
137
+ wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => message})
138
+ wait.until &block
139
+ end
140
+ #
141
+ # Waits until the block returns true
142
+ #
143
+ # @param [Integer] (defaults to: 5) seconds to wait before timing out
144
+ # @param [String] the message to display if the event timeouts
145
+ # @param the block to execute when the event occurrs
146
+ #
147
+ def wait_until(timeout=5, message=nil, &block)
148
+ wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => message})
149
+ wait.until &block
150
+ end
151
+
152
+ #
153
+ # Send keystrokes to this element
154
+ #
155
+ # @param [String, Symbol, Array]
156
+ #
157
+ # Examples:
158
+ #
159
+ # element.send_keys "foo" #=> value: 'foo'
160
+ # element.send_keys "tet", :arrow_left, "s" #=> value: 'test'
161
+ # element.send_keys [:control, 'a'], :space #=> value: ' '
162
+ #
163
+ # @see Selenium::WebDriver::Keys::KEYS
164
+ #
165
+ end
166
+ end
167
+ end
168
+ end