jarib-celerity 0.0.6.7 → 0.0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. data/README.txt +4 -0
  2. data/lib/celerity/browser.rb +36 -21
  3. data/lib/celerity/clickable_element.rb +16 -1
  4. data/lib/celerity/collections.rb +2 -2
  5. data/lib/celerity/default_viewer.rb +1 -1
  6. data/lib/celerity/disabled_element.rb +5 -5
  7. data/lib/celerity/element.rb +25 -21
  8. data/lib/celerity/element_collection.rb +14 -14
  9. data/lib/celerity/element_locator.rb +9 -9
  10. data/lib/celerity/elements/button.rb +9 -9
  11. data/lib/celerity/elements/file_field.rb +3 -3
  12. data/lib/celerity/elements/form.rb +5 -5
  13. data/lib/celerity/elements/frame.rb +2 -2
  14. data/lib/celerity/elements/image.rb +2 -2
  15. data/lib/celerity/elements/label.rb +1 -1
  16. data/lib/celerity/elements/link.rb +4 -4
  17. data/lib/celerity/elements/non_control_elements.rb +3 -3
  18. data/lib/celerity/elements/option.rb +5 -5
  19. data/lib/celerity/elements/radio_check.rb +16 -16
  20. data/lib/celerity/elements/select_list.rb +16 -16
  21. data/lib/celerity/elements/table.rb +15 -12
  22. data/lib/celerity/elements/table_row.rb +3 -3
  23. data/lib/celerity/elements/text_field.rb +22 -25
  24. data/lib/celerity/exception.rb +5 -5
  25. data/lib/celerity/htmlunit.rb +8 -2
  26. data/lib/celerity/htmlunit/htmlunit-2.6-SNAPSHOT.jar +0 -0
  27. data/lib/celerity/htmlunit/{nekohtml-1.9.12.jar → nekohtml-1.9.13-20090507.082850-2.jar} +0 -0
  28. data/lib/celerity/listener.rb +17 -17
  29. data/lib/celerity/util.rb +1 -1
  30. data/lib/celerity/version.rb +2 -2
  31. data/lib/celerity/watir_compatibility.rb +2 -2
  32. metadata +7 -9
  33. data/lib/celerity/extra/method_generator.rb +0 -170
  34. data/lib/celerity/htmlunit/htmlunit-2.5.jar +0 -0
@@ -21,31 +21,33 @@ module Celerity
21
21
  end
22
22
  end
23
23
  end
24
+
25
+ @object
24
26
  end
25
-
27
+
26
28
  #
27
29
  # @return [Celerity::TableRows]
28
30
  #
29
-
31
+
30
32
  def rows
31
33
  assert_exists
32
34
  TableRows.new(self, :object, @rows)
33
35
  end
34
-
36
+
35
37
  #
36
38
  # @return [Celerity::TableCells]
37
39
  #
38
-
40
+
39
41
  def cells
40
42
  assert_exists
41
43
  TableCells.new(self, :object, @cells)
42
44
  end
43
-
45
+
44
46
  #
45
47
  # Iterates through each row in the table.
46
48
  # @yieldparam [Celerity::TableRow] row A row.
47
49
  #
48
-
50
+
49
51
  def each
50
52
  assert_exists
51
53
  @rows.each { |row| yield TableRow.new(self, :object, row) }
@@ -61,7 +63,7 @@ module Celerity
61
63
  # @raise [Celerity::Exception::UnknownRowException]
62
64
  # @return [Celerity::TableRow]
63
65
  #
64
-
66
+
65
67
  def child_row(index)
66
68
  assert_exists
67
69
 
@@ -82,13 +84,14 @@ module Celerity
82
84
  # @raise [Celerity::Exception::UnknownCellException]
83
85
  # @return [Celerity::TableCell]
84
86
  #
85
-
87
+
86
88
  def child_cell(index)
87
89
  assert_exists
88
90
 
89
91
  if (index - INDEX_OFFSET) >= @cells.length
90
92
  raise UnknownCellException, "Unable to locate a cell at index #{index}"
91
93
  end
94
+
92
95
  TableCell.new(self, :object, @cells[index - INDEX_OFFSET])
93
96
  end
94
97
 
@@ -96,19 +99,19 @@ module Celerity
96
99
  # The number of rows in the table
97
100
  # @return [Fixnum]
98
101
  #
99
-
102
+
100
103
  def row_count
101
104
  assert_exists
102
105
  @object.getRowCount
103
106
  end
104
-
107
+
105
108
  #
106
109
  # Returns the number of columns on the row at the given index. (1-indexed)
107
110
  # Default is the number of columns on the first row
108
111
  # @param [Fixnum] index An index, 1-indexed (optional).
109
112
  # @return [Fixnum]
110
113
  #
111
-
114
+
112
115
  def column_count(index = INDEX_OFFSET)
113
116
  assert_exists
114
117
  @object.getRow(index - INDEX_OFFSET).getCells.length
@@ -118,7 +121,7 @@ module Celerity
118
121
  # Returns the text of each cell in the the table as a two-dimensional array.
119
122
  # @return [Array<Array<String>>]
120
123
  #
121
-
124
+
122
125
  def to_a
123
126
  assert_exists
124
127
  # @object.getRows.map do |table_row|
@@ -14,7 +14,7 @@ module Celerity
14
14
  #
15
15
  # Yields each TableCell in this row to the given block.
16
16
  #
17
-
17
+
18
18
  def each
19
19
  assert_exists
20
20
  @cells.each { |cell| yield TableCell.new(self, :object, cell) }
@@ -23,7 +23,7 @@ module Celerity
23
23
  #
24
24
  # Get the child cell at the given index
25
25
  #
26
-
26
+
27
27
  def child_cell(index)
28
28
  assert_exists
29
29
 
@@ -38,7 +38,7 @@ module Celerity
38
38
  #
39
39
  # Number of cells in this row.
40
40
  #
41
-
41
+
42
42
  def column_count
43
43
  assert_exists
44
44
  @cells.length
@@ -1,49 +1,49 @@
1
1
  module Celerity
2
-
2
+
3
3
  #
4
4
  # Class representing text field elements
5
5
  #
6
6
  # This class is the main class for Text Fields
7
7
  # Normally a user would not need to create this object as it is returned by the Watir::Container#text_field method
8
8
  #
9
-
9
+
10
10
  class TextField < InputElement
11
11
  NON_TEXT_TYPES = %w[file radio checkbox submit reset image button hidden]
12
12
  TAGS = [ Identifier.new('textarea'),
13
13
  Identifier.new('input', :type => ["text", "password", /^(?!(#{ Regexp.union(*NON_TEXT_TYPES) })$)/]) ]
14
14
  DEFAULT_HOW = :name
15
-
15
+
16
16
  def visible?
17
17
  assert_exists
18
18
  type == 'hidden' ? false : super
19
19
  end
20
-
20
+
21
21
  #
22
22
  # Clear the text field.
23
23
  #
24
-
24
+
25
25
  def clear
26
26
  assert_exists
27
27
  insert_string ''
28
28
  end
29
-
29
+
30
30
  #
31
31
  # Set the text field to the given value.
32
32
  # This ensures execution of JavaScript events (onkeypress etc.), but is slower than +value=+
33
33
  #
34
-
34
+
35
35
  def set(value)
36
36
  assert_enabled
37
37
  assert_not_readonly
38
38
  clear
39
39
  type_string(value.to_s)
40
40
  end
41
-
41
+
42
42
  #
43
43
  # This directly sets the text field to the given value, skipping exectuion of JavaScript events.
44
44
  # Use +set+ if you want to run events on text fields.
45
45
  #
46
-
46
+
47
47
  def value=(value)
48
48
  assert_enabled
49
49
  assert_not_readonly
@@ -53,11 +53,11 @@ module Celerity
53
53
 
54
54
  value
55
55
  end
56
-
56
+
57
57
  #
58
58
  # Returns the text in the text field.
59
59
  #
60
-
60
+
61
61
  def value
62
62
  assert_exists
63
63
  case @object.getTagName
@@ -68,34 +68,30 @@ module Celerity
68
68
  end
69
69
  end
70
70
  alias_method :get_contents, :value
71
-
71
+
72
72
  #
73
73
  # Append the given value to the text in the text field.
74
74
  #
75
-
75
+
76
76
  def append(value)
77
77
  assert_enabled
78
78
  assert_not_readonly
79
79
  type_string(value)
80
80
  end
81
81
 
82
-
82
+
83
83
  def type
84
84
  assert_exists
85
85
  type = @object.getAttribute 'type'
86
86
 
87
- if NON_TEXT_TYPES.include?(type)
88
- type
89
- else
90
- 'text'
91
- end
87
+ NON_TEXT_TYPES.include?(type) ? type : 'text'
92
88
  end
93
89
 
94
90
  #
95
91
  # This bascially just moves the text to the other text field using TextField#append
96
92
  # TODO: check if HtmlUnit supports some kind of dragging.
97
93
  #
98
-
94
+
99
95
  def drag_contents_to(how, what)
100
96
  assert_exists # assert_enabled?
101
97
  val = self.value
@@ -106,7 +102,7 @@ module Celerity
106
102
  #
107
103
  # Check if the given text fields contains the given String or Regexp.
108
104
  #
109
-
105
+
110
106
  def contains_text(expected_text)
111
107
  assert_exists
112
108
 
@@ -122,10 +118,11 @@ module Celerity
122
118
 
123
119
  #
124
120
  # A boolean version of TextField#contains_text
121
+ #
125
122
  # @param [String, Regexp] expected_text The text to look for.
126
123
  # @return [boolean]
127
124
  #
128
-
125
+
129
126
  def verify_contains(expected)
130
127
  # assert_exists called by contains_text
131
128
  !!contains_text(expected)
@@ -149,18 +146,18 @@ module Celerity
149
146
  raise "unknown tag name #{@object.getTagName.inspect} for #{self.class}"
150
147
  end
151
148
  end
152
-
149
+
153
150
  end # TextField
154
151
 
155
152
  #
156
153
  # This class can be used to access hidden field objects
157
154
  # Normally a user would not need to create this object as it is returned by the Celerity::Container#hidden method
158
155
  #
159
-
156
+
160
157
  class Hidden < TextField
161
158
  TAGS = [ Identifier.new('input', :type => %w[hidden]) ]
162
159
  DEFAULT_HOW = :name
163
-
160
+
164
161
  def visible?
165
162
  assert_exists
166
163
  false
@@ -1,6 +1,6 @@
1
1
  module Celerity
2
2
  module Exception
3
-
3
+
4
4
  #
5
5
  # Superclass for all Celerity exceptions.
6
6
  #
@@ -12,7 +12,7 @@ module Celerity
12
12
  #
13
13
 
14
14
  class UnknownObjectException < CelerityException; end
15
-
15
+
16
16
  #
17
17
  # This exception is thrown if an attempt is made to access an object that is in a disabled state
18
18
  #
@@ -54,7 +54,7 @@ module Celerity
54
54
  #
55
55
 
56
56
  class UnknownRowException < CelerityException; end
57
-
57
+
58
58
  #
59
59
  # This exception is raised if an attempt is made to access a table cell that doesn't exist
60
60
  #
@@ -66,12 +66,12 @@ module Celerity
66
66
  #
67
67
 
68
68
  class NavigationException < CelerityException; end
69
-
69
+
70
70
  #
71
71
  # This exception is thrown if an unexpected content type is returned by the server.
72
72
  #
73
73
 
74
74
  class UnexpectedPageException < CelerityException; end
75
-
75
+
76
76
  end # Exception
77
77
  end # Celerity
@@ -1,7 +1,7 @@
1
1
  module Celerity
2
2
  Jars = Dir[File.dirname(__FILE__) + '/htmlunit/*.jar']
3
3
  Jars.each { |jar| require(jar) }
4
-
4
+
5
5
  include_class org.apache.commons.httpclient.Cookie
6
6
  end
7
7
 
@@ -11,7 +11,7 @@ module HtmlUnit
11
11
  module Html
12
12
  include_package 'com.gargoylesoftware.htmlunit.html'
13
13
  end
14
-
14
+
15
15
  module Util
16
16
  include_package 'com.gargoylesoftware.htmlunit.util'
17
17
  end
@@ -42,3 +42,9 @@ class Java::ComGargoylesoftwareHtmlunitHtml::HtmlPage
42
42
  '#<HtmlPage:0x%s(%s)>' % [self.hash.to_s(16), getWebResponse.getRequestUrl.toString]
43
43
  end
44
44
  end
45
+
46
+ class Java::ComGargoylesoftwareHtmlunitHtml::HtmlElement
47
+ def inspect
48
+ '#<%s:0x%s>' % [self.class.name.split("::").last, self.hash.to_s(16)]
49
+ end
50
+ end
@@ -3,7 +3,7 @@ module Celerity
3
3
  #
4
4
  # This class is used to wrap some of the listeners available from HtmlUnit's WebClient.
5
5
  #
6
-
6
+
7
7
  class Listener
8
8
  include com.gargoylesoftware.htmlunit.AlertHandler
9
9
  include com.gargoylesoftware.htmlunit.ConfirmHandler
@@ -18,12 +18,12 @@ module Celerity
18
18
  @webclient = webclient
19
19
  @procs = Hash.new { |h, k| h[k] = [] }
20
20
  end
21
-
21
+
22
22
  #
23
23
  # Add a listener block for one of the available types.
24
24
  # @see Celerity::Browser#add_listener
25
25
  #
26
-
26
+
27
27
  def add_listener(type, &block)
28
28
  case type
29
29
  when :status
@@ -63,23 +63,23 @@ module Celerity
63
63
  raise TypeError, "must give proc or index"
64
64
  end
65
65
  end
66
-
66
+
67
67
  #
68
68
  # interface StatusHandler
69
69
  #
70
-
70
+
71
71
  def statusMessageChanged(page, message)
72
72
  @procs[:status].each { |h| h.call(page, message) }
73
73
  end
74
-
74
+
75
75
  #
76
76
  # interface AlertHandler
77
77
  #
78
-
78
+
79
79
  def handleAlert(page, message)
80
80
  @procs[:alert].each { |h| h.call(page, message) }
81
81
  end
82
-
82
+
83
83
  #
84
84
  # interface ConfirmHandler
85
85
  #
@@ -87,8 +87,8 @@ module Celerity
87
87
  # If it is nil, return true, otherwise return that value as a boolean.
88
88
  #
89
89
  # @see Browser#confirm
90
- #
91
-
90
+ #
91
+
92
92
  def handleConfirm(page, message)
93
93
  val = @procs[:confirm].map { |h| h.call(page, message) }.last
94
94
  val.nil? || !!val
@@ -97,23 +97,23 @@ module Celerity
97
97
  #
98
98
  # interface AttachmentHandler
99
99
  #
100
-
100
+
101
101
  def handleAttachment(page)
102
102
  @procs[:attachment].each { |h| h.call(page) }
103
103
  end
104
-
104
+
105
105
  #
106
106
  # interface PromptHandler
107
107
  #
108
-
108
+
109
109
  def handlePrompt(page, message)
110
110
  @procs[:prompt].each { |h| h.call(page, message) }
111
111
  end
112
-
112
+
113
113
  #
114
114
  # interface WebWindowListener
115
115
  #
116
-
116
+
117
117
  def webWindowClosed(web_window_event)
118
118
  @procs[:web_window_event].each { |h| h.call(web_window_event) }
119
119
  end
@@ -123,7 +123,7 @@ module Celerity
123
123
  #
124
124
  # interface HTMLParserListener
125
125
  #
126
-
126
+
127
127
  def error(message, url, line, column, key)
128
128
  @procs[:html_parser].each { |h| h.call(message, url, line, column, key) }
129
129
  end
@@ -132,7 +132,7 @@ module Celerity
132
132
  #
133
133
  # interface IncorrectnessListener
134
134
  #
135
-
135
+
136
136
  def notify(message, origin)
137
137
  @procs[:incorrectness].each { |h| h.call(message, origin) }
138
138
  end