jarib-celerity 0.0.5.5 → 0.0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/celerity/browser.rb +220 -83
- data/lib/celerity/collections.rb +39 -39
- data/lib/celerity/container.rb +272 -20
- data/lib/celerity/disabled_element.rb +16 -3
- data/lib/celerity/element.rb +48 -3
- data/lib/celerity/element_locator.rb +3 -0
- data/lib/celerity/elements/button.rb +16 -6
- data/lib/celerity/elements/file_field.rb +10 -2
- data/lib/celerity/elements/form.rb +7 -2
- data/lib/celerity/elements/frame.rb +25 -4
- data/lib/celerity/elements/image.rb +22 -3
- data/lib/celerity/elements/non_control_elements.rb +6 -1
- data/lib/celerity/elements/option.rb +9 -1
- data/lib/celerity/elements/radio_check.rb +44 -14
- data/lib/celerity/elements/select_list.rb +29 -5
- data/lib/celerity/elements/table.rb +30 -7
- data/lib/celerity/elements/table_cell.rb +2 -2
- data/lib/celerity/elements/table_row.rb +14 -3
- data/lib/celerity/elements/text_field.rb +46 -9
- data/lib/celerity/exception.rb +43 -6
- data/lib/celerity/extra/method_generator.rb +13 -1
- data/lib/celerity/htmlunit.rb +6 -1
- data/lib/celerity/listener.rb +37 -8
- data/lib/celerity/util.rb +3 -0
- data/lib/celerity/version.rb +1 -1
- data/lib/celerity/watir_compatibility.rb +12 -11
- data/lib/celerity.rb +1 -1
- metadata +4 -3
- data/lib/celerity/element_collections.rb +0 -82
@@ -3,30 +3,42 @@ module Celerity
|
|
3
3
|
TAGS = [ Identifier.new('select') ]
|
4
4
|
DEFAULT_HOW = :name
|
5
5
|
|
6
|
+
#
|
6
7
|
# @return [Array<String>] An array of strings representing the text value of the select list's options.
|
8
|
+
#
|
9
|
+
|
7
10
|
def options
|
8
11
|
assert_exists
|
9
12
|
@object.getOptions.map { |e| e.asText }
|
10
13
|
end
|
11
|
-
|
14
|
+
|
15
|
+
#
|
12
16
|
# @return [Array<String>] An array of strings representing the text value of the currently selected options.
|
17
|
+
#
|
18
|
+
|
13
19
|
def selected_options
|
14
20
|
assert_exists
|
15
21
|
@object.getSelectedOptions.map { |e| e.asText }
|
16
22
|
end
|
17
|
-
|
23
|
+
|
24
|
+
#
|
18
25
|
# Clear all selected options
|
19
|
-
#
|
26
|
+
#
|
27
|
+
|
20
28
|
def clear
|
21
29
|
# assert_exists called by SelectList#type here
|
30
|
+
# TODO: should update page for each option changed?
|
22
31
|
@object.getSelectedOptions.each { |e| e.setSelected(false) } unless type() == 'select-one'
|
23
32
|
end
|
24
33
|
|
34
|
+
#
|
25
35
|
# Select the option(s) matching the given value.
|
26
36
|
# If several options match the value given, all will be selected.
|
27
37
|
#
|
28
38
|
# @param [String, Regexp] value A value.
|
29
39
|
# @raise [Celerity::Exception::NoValueFoundException] if the value does not exist.
|
40
|
+
#
|
41
|
+
|
30
42
|
def select(value)
|
31
43
|
assert_exists
|
32
44
|
raise NoValueFoundException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}" unless include?(value)
|
@@ -36,40 +48,52 @@ module Celerity
|
|
36
48
|
end
|
37
49
|
alias_method :set, :select
|
38
50
|
|
51
|
+
#
|
39
52
|
# Returns true if the select list has one or more options matching the given value.
|
40
53
|
#
|
41
54
|
# @param [String, Regexp] value A value.
|
42
55
|
# @return [true, false]
|
56
|
+
#
|
57
|
+
|
43
58
|
def include?(value)
|
44
59
|
assert_exists
|
45
60
|
!!@object.getOptions.find { |e| matches?(e.asText, value) }
|
46
61
|
end
|
47
62
|
|
63
|
+
#
|
48
64
|
# Returns true if any of the selected options match the given value.
|
49
65
|
#
|
50
66
|
# @param [String, Regexp] value A value.
|
51
67
|
# @raise [Celerity::Exception::UnknownObjectException] if the value does not exist.
|
52
68
|
# @return [true, false]
|
69
|
+
#
|
70
|
+
|
53
71
|
def selected?(value)
|
54
72
|
assert_exists
|
55
73
|
raise UnknownObjectException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}" unless include?(value)
|
56
74
|
!!@object.getOptions.find { |e| matches?(e.asText, value) && e.isSelected }
|
57
75
|
end
|
58
76
|
|
77
|
+
#
|
59
78
|
# Returns 'select-multiple' if the select list has the 'multiple' attribute,
|
60
79
|
# defined, otherwise 'select-one'.
|
61
80
|
#
|
62
81
|
# @return [String]
|
63
82
|
# TODO: Move to watir_compatibility or delete it 2008-05-23 Alexander
|
83
|
+
#
|
84
|
+
|
64
85
|
def type
|
65
86
|
assert_exists
|
66
87
|
'select-' + (@object.isAttributeDefined('multiple') ? 'multiple' : 'one')
|
67
88
|
end
|
68
89
|
|
90
|
+
#
|
69
91
|
# Returns the value of the first selected option in the select list.
|
70
92
|
# Returns nil if no option is selected.
|
71
93
|
#
|
72
94
|
# @return [String, nil]
|
95
|
+
#
|
96
|
+
|
73
97
|
def value
|
74
98
|
assert_exists
|
75
99
|
if (optn = @object.getSelectedOptions.to_a.first)
|
@@ -77,5 +101,5 @@ module Celerity
|
|
77
101
|
end
|
78
102
|
end
|
79
103
|
|
80
|
-
end
|
81
|
-
end
|
104
|
+
end # SelectList
|
105
|
+
end # Celerity
|
@@ -22,26 +22,36 @@ module Celerity
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
|
+
#
|
26
27
|
# @return [Celerity::TableRows]
|
28
|
+
#
|
29
|
+
|
27
30
|
def rows
|
28
31
|
assert_exists
|
29
32
|
TableRows.new(self, :object, @rows)
|
30
33
|
end
|
31
|
-
|
34
|
+
|
35
|
+
#
|
32
36
|
# @return [Celerity::TableCells]
|
37
|
+
#
|
38
|
+
|
33
39
|
def cells
|
34
40
|
assert_exists
|
35
41
|
TableCells.new(self, :object, @cells)
|
36
42
|
end
|
37
|
-
|
43
|
+
|
44
|
+
#
|
38
45
|
# Iterates through each row in the table.
|
39
46
|
# @yieldparam [Celerity::TableRow] row A row.
|
47
|
+
#
|
48
|
+
|
40
49
|
def each
|
41
50
|
assert_exists
|
42
51
|
@rows.each { |row| yield TableRow.new(self, :object, row) }
|
43
52
|
end
|
44
53
|
|
54
|
+
#
|
45
55
|
# Returns the TableRow at the given index (1-indexed).
|
46
56
|
#
|
47
57
|
# browser.table(:foo, 'bar')[1] # => #<TableRow...>
|
@@ -50,6 +60,8 @@ module Celerity
|
|
50
60
|
# @param [Fixnum] index The index of the wanted row, 1-indexed.
|
51
61
|
# @raise [Celerity::Exception::UnknownRowException]
|
52
62
|
# @return [Celerity::TableRow]
|
63
|
+
#
|
64
|
+
|
53
65
|
def child_row(index)
|
54
66
|
assert_exists
|
55
67
|
|
@@ -61,6 +73,7 @@ module Celerity
|
|
61
73
|
end
|
62
74
|
alias_method :[], :child_row
|
63
75
|
|
76
|
+
#
|
64
77
|
# Returns the TableCell at the given index (1-indexed).
|
65
78
|
#
|
66
79
|
# In a 10-column row, table.child_cell[11] will return the first cell on the second row.
|
@@ -68,6 +81,8 @@ module Celerity
|
|
68
81
|
# @param [Fixnum] index The index of the wanted cell, 1-indexed.
|
69
82
|
# @raise [Celerity::Exception::UnknownCellException]
|
70
83
|
# @return [Celerity::TableCell]
|
84
|
+
#
|
85
|
+
|
71
86
|
def child_cell(index)
|
72
87
|
assert_exists
|
73
88
|
|
@@ -77,24 +92,33 @@ module Celerity
|
|
77
92
|
TableCell.new(self, :object, @cells[index - INDEX_OFFSET])
|
78
93
|
end
|
79
94
|
|
95
|
+
#
|
80
96
|
# The number of rows in the table
|
81
97
|
# @return [Fixnum]
|
98
|
+
#
|
99
|
+
|
82
100
|
def row_count
|
83
101
|
assert_exists
|
84
102
|
@object.getRowCount
|
85
103
|
end
|
86
|
-
|
104
|
+
|
105
|
+
#
|
87
106
|
# Returns the number of columns on the row at the given index. (1-indexed)
|
88
107
|
# Default is the number of columns on the first row
|
89
108
|
# @param [Fixnum] index An index, 1-indexed (optional).
|
90
109
|
# @return [Fixnum]
|
110
|
+
#
|
111
|
+
|
91
112
|
def column_count(index = INDEX_OFFSET)
|
92
113
|
assert_exists
|
93
114
|
@object.getRow(index - INDEX_OFFSET).getCells.length
|
94
115
|
end
|
95
116
|
|
117
|
+
#
|
96
118
|
# Returns the text of each cell in the the table as a two-dimensional array.
|
97
119
|
# @return [Array<Array<String>>]
|
120
|
+
#
|
121
|
+
|
98
122
|
def to_a
|
99
123
|
assert_exists
|
100
124
|
# @object.getRows.map do |table_row|
|
@@ -113,6 +137,5 @@ module Celerity
|
|
113
137
|
(1..column_count(row_number)).map { |index| self[row_number][index].text }
|
114
138
|
end
|
115
139
|
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
140
|
+
end # Table
|
141
|
+
end # Celerity
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Celerity
|
2
2
|
|
3
3
|
class TableCell < Element
|
4
|
-
include ClickableElement
|
5
4
|
include Celerity::Exception
|
5
|
+
include ClickableElement
|
6
6
|
include Container
|
7
7
|
|
8
8
|
TAGS = [ Identifier.new('td') ]
|
@@ -21,7 +21,7 @@ module Celerity
|
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
#-- needs code review regarding attributes/correctness of this
|
25
25
|
class Th < TableCell
|
26
26
|
TAGS = [ Identifier.new('th')]
|
27
27
|
end
|
@@ -11,12 +11,19 @@ module Celerity
|
|
11
11
|
@cells = @object.getCells if @object
|
12
12
|
end
|
13
13
|
|
14
|
-
#
|
14
|
+
#
|
15
|
+
# Yields each TableCell in this row to the given block.
|
16
|
+
#
|
17
|
+
|
15
18
|
def each
|
16
19
|
assert_exists
|
17
20
|
@cells.each { |cell| yield TableCell.new(self, :object, cell) }
|
18
21
|
end
|
19
22
|
|
23
|
+
#
|
24
|
+
# Get the child cell at the given index
|
25
|
+
#
|
26
|
+
|
20
27
|
def child_cell(index)
|
21
28
|
assert_exists
|
22
29
|
|
@@ -28,10 +35,14 @@ module Celerity
|
|
28
35
|
end
|
29
36
|
alias_method :[], :child_cell
|
30
37
|
|
38
|
+
#
|
39
|
+
# Number of cells in this row.
|
40
|
+
#
|
41
|
+
|
31
42
|
def column_count
|
32
43
|
assert_exists
|
33
44
|
@cells.length
|
34
45
|
end
|
35
46
|
|
36
|
-
end
|
37
|
-
end
|
47
|
+
end # TableRow
|
48
|
+
end # Celerity
|
@@ -1,32 +1,44 @@
|
|
1
1
|
module Celerity
|
2
|
+
|
2
3
|
#
|
3
4
|
# Class representing text field elements
|
4
5
|
#
|
5
6
|
# This class is the main class for Text Fields
|
6
7
|
# Normally a user would not need to create this object as it is returned by the Watir::Container#text_field method
|
8
|
+
#
|
9
|
+
|
7
10
|
class TextField < InputElement
|
8
11
|
NON_TEXT_TYPES = %w[file radio checkbox submit reset image button hidden]
|
9
12
|
TAGS = [ Identifier.new('textarea'),
|
10
13
|
Identifier.new('input', :type => ["text", "password", /^(?!(#{ Regexp.union(*NON_TEXT_TYPES) })$)/]) ]
|
11
14
|
DEFAULT_HOW = :name
|
12
|
-
|
15
|
+
|
16
|
+
#
|
13
17
|
# Clear the text field.
|
18
|
+
#
|
19
|
+
|
14
20
|
def clear
|
15
21
|
assert_exists
|
16
22
|
insert_string ''
|
17
23
|
end
|
18
|
-
|
24
|
+
|
25
|
+
#
|
19
26
|
# Set the text field to the given value.
|
20
27
|
# This ensures execution of JavaScript events (onkeypress etc.), but is slower than +value=+
|
28
|
+
#
|
29
|
+
|
21
30
|
def set(value)
|
22
31
|
assert_enabled
|
23
32
|
assert_not_readonly
|
24
33
|
clear
|
25
34
|
type_string(value.to_s)
|
26
35
|
end
|
27
|
-
|
36
|
+
|
37
|
+
#
|
28
38
|
# This directly sets the text field to the given value, skipping exectuion of JavaScript events.
|
29
39
|
# Use +set+ if you want to run events on text fields.
|
40
|
+
#
|
41
|
+
|
30
42
|
def value=(value)
|
31
43
|
assert_enabled
|
32
44
|
assert_not_readonly
|
@@ -36,8 +48,11 @@ module Celerity
|
|
36
48
|
|
37
49
|
value
|
38
50
|
end
|
39
|
-
|
51
|
+
|
52
|
+
#
|
40
53
|
# Returns the text in the text field.
|
54
|
+
#
|
55
|
+
|
41
56
|
def value
|
42
57
|
assert_exists
|
43
58
|
case @object.getTagName
|
@@ -48,14 +63,18 @@ module Celerity
|
|
48
63
|
end
|
49
64
|
end
|
50
65
|
alias_method :get_contents, :value
|
51
|
-
|
66
|
+
|
67
|
+
#
|
52
68
|
# Append the given value to the text in the text field.
|
69
|
+
#
|
70
|
+
|
53
71
|
def append(value)
|
54
72
|
assert_enabled
|
55
73
|
assert_not_readonly
|
56
74
|
type_string(value)
|
57
75
|
end
|
58
76
|
|
77
|
+
|
59
78
|
def type
|
60
79
|
assert_exists
|
61
80
|
type = @object.getAttributeValue('type')
|
@@ -67,8 +86,11 @@ module Celerity
|
|
67
86
|
end
|
68
87
|
end
|
69
88
|
|
89
|
+
#
|
70
90
|
# This bascially just moves the text to the other text field using TextField#append
|
71
|
-
#
|
91
|
+
# TODO: check if HtmlUnit supports some kind of dragging.
|
92
|
+
#
|
93
|
+
|
72
94
|
def drag_contents_to(how, what)
|
73
95
|
assert_exists # assert_enabled?
|
74
96
|
val = self.value
|
@@ -76,6 +98,10 @@ module Celerity
|
|
76
98
|
@container.text_field(how, what).append(val)
|
77
99
|
end
|
78
100
|
|
101
|
+
#
|
102
|
+
# Check if the given text fields contains the given String or Regexp.
|
103
|
+
#
|
104
|
+
|
79
105
|
def contains_text(expected_text)
|
80
106
|
assert_exists
|
81
107
|
|
@@ -89,9 +115,12 @@ module Celerity
|
|
89
115
|
end
|
90
116
|
end
|
91
117
|
|
118
|
+
#
|
92
119
|
# A boolean version of TextField#contains_text
|
93
120
|
# @param [String, Regexp] expected_text The text to look for.
|
94
121
|
# @return [boolean]
|
122
|
+
#
|
123
|
+
|
95
124
|
def verify_contains(expected)
|
96
125
|
# assert_exists called by contains_text
|
97
126
|
!!contains_text(expected)
|
@@ -115,13 +144,21 @@ module Celerity
|
|
115
144
|
raise "unknown tag name #{@object.getTagName.inspect} for #{self.class}"
|
116
145
|
end
|
117
146
|
end
|
118
|
-
|
147
|
+
|
148
|
+
end # TextField
|
119
149
|
|
120
|
-
#
|
150
|
+
#
|
151
|
+
# This class can be used to access hidden field objects
|
121
152
|
# Normally a user would not need to create this object as it is returned by the Celerity::Container#hidden method
|
153
|
+
#
|
154
|
+
|
122
155
|
class Hidden < TextField
|
123
156
|
TAGS = [ Identifier.new('input', :type => %w[hidden]) ]
|
124
157
|
DEFAULT_HOW = :name
|
158
|
+
|
159
|
+
def visible?
|
160
|
+
false
|
161
|
+
end
|
125
162
|
end
|
126
163
|
|
127
|
-
end
|
164
|
+
end # Celerity
|
data/lib/celerity/exception.rb
CHANGED
@@ -1,40 +1,77 @@
|
|
1
1
|
module Celerity
|
2
2
|
module Exception
|
3
|
-
|
3
|
+
|
4
|
+
#
|
4
5
|
# Superclass for all Celerity exceptions.
|
6
|
+
#
|
7
|
+
|
5
8
|
class CelerityException < StandardError; end
|
6
9
|
|
10
|
+
#
|
7
11
|
# This exception is thrown if an attempt is made to access an object that doesn't exist
|
8
|
-
|
12
|
+
#
|
9
13
|
|
14
|
+
class UnknownObjectException < CelerityException; end
|
15
|
+
|
16
|
+
#
|
10
17
|
# This exception is thrown if an attempt is made to access an object that is in a disabled state
|
18
|
+
#
|
19
|
+
|
11
20
|
class ObjectDisabledException < CelerityException; end
|
12
21
|
|
22
|
+
#
|
13
23
|
# This exception is thrown if an attempt is made to access a frame that cannot be found
|
24
|
+
#
|
25
|
+
|
14
26
|
class UnknownFrameException < CelerityException; end
|
15
27
|
|
28
|
+
#
|
16
29
|
# This exception is thrown if an attempt is made to access a form that cannot be found
|
30
|
+
#
|
31
|
+
|
17
32
|
class UnknownFormException < CelerityException; end
|
18
33
|
|
34
|
+
#
|
19
35
|
# This exception is thrown if an attempt is made to access an object that is in a read-only state
|
36
|
+
#
|
37
|
+
|
20
38
|
class ObjectReadOnlyException < CelerityException; end
|
21
39
|
|
40
|
+
#
|
22
41
|
# This exception is thrown if an attempt is made to access an object when the specified value cannot be found
|
42
|
+
#
|
43
|
+
|
23
44
|
class NoValueFoundException < CelerityException; end
|
24
45
|
|
46
|
+
#
|
25
47
|
# This exception gets raised if the how argument is wrong.
|
48
|
+
#
|
49
|
+
|
26
50
|
class MissingWayOfFindingObjectException < CelerityException; end
|
27
51
|
|
52
|
+
#
|
28
53
|
# This exception is raised if an attempt is made to access a table row that doesn't exist
|
29
|
-
|
54
|
+
#
|
30
55
|
|
56
|
+
class UnknownRowException < CelerityException; end
|
57
|
+
|
58
|
+
#
|
31
59
|
# This exception is raised if an attempt is made to access a table cell that doesn't exist
|
60
|
+
#
|
61
|
+
|
32
62
|
class UnknownCellException < CelerityException; end
|
33
63
|
|
64
|
+
#
|
34
65
|
# This exception is thrown if an http error, such as a 404, 500 etc is encountered while navigating
|
35
|
-
|
66
|
+
#
|
36
67
|
|
68
|
+
class NavigationException < CelerityException; end
|
69
|
+
|
70
|
+
#
|
37
71
|
# This exception is thrown if an unexpected content type is returned by the server.
|
72
|
+
#
|
73
|
+
|
38
74
|
class UnexpectedPageException < CelerityException; end
|
39
|
-
|
40
|
-
end
|
75
|
+
|
76
|
+
end # Exception
|
77
|
+
end # Celerity
|
@@ -16,7 +16,15 @@ class String # :nodoc:
|
|
16
16
|
end
|
17
17
|
|
18
18
|
module Celerity
|
19
|
+
|
20
|
+
#
|
19
21
|
# Experimental - generate a method definition for accessing elements on the current page.
|
22
|
+
#
|
23
|
+
# Usage:
|
24
|
+
#
|
25
|
+
# MethodGenerator.new(browser, opts).parse
|
26
|
+
#
|
27
|
+
#
|
20
28
|
class MethodGenerator
|
21
29
|
|
22
30
|
ELEMENTS = %w[text_field select_list radio checkbox button].map { |e| e.to_sym }
|
@@ -135,13 +143,17 @@ module Celerity
|
|
135
143
|
end # MethodGenerator
|
136
144
|
|
137
145
|
class Browser
|
146
|
+
|
147
|
+
#
|
138
148
|
# Experimental - generate a method definition for accessing elements on the current page
|
139
149
|
# Not loaded by default - need to require 'celerity/extra/method_generator'
|
150
|
+
#
|
151
|
+
|
140
152
|
def generate_method(opts = {})
|
141
153
|
MethodGenerator.new(self, opts).parse
|
142
154
|
end
|
155
|
+
|
143
156
|
end # Browser
|
144
|
-
|
145
157
|
end # Celerity
|
146
158
|
|
147
159
|
|
data/lib/celerity/htmlunit.rb
CHANGED
@@ -27,7 +27,6 @@ module Java::OrgW3cDom::NamedNodeMap
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
# this will be added in JRuby 1.1.6
|
31
30
|
module Java::JavaLang::Iterable
|
32
31
|
include Enumerable
|
33
32
|
|
@@ -39,3 +38,9 @@ module Java::JavaLang::Iterable
|
|
39
38
|
end
|
40
39
|
|
41
40
|
|
41
|
+
class Java::ComGargoylesoftwareHtmlunitHtml::HtmlPage
|
42
|
+
def inspect
|
43
|
+
'#<HtmlPage:0x%s(%s)>' % [self.hash.to_s(16), getWebResponse.getUrl.toString]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/lib/celerity/listener.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module Celerity
|
2
2
|
|
3
|
-
#
|
4
|
-
# from HtmlUnit's WebClient.
|
3
|
+
#
|
4
|
+
# This class is used to wrap some of the listeners available from HtmlUnit's WebClient.
|
5
|
+
#
|
6
|
+
|
5
7
|
class Listener
|
6
8
|
include com.gargoylesoftware.htmlunit.AlertHandler
|
7
9
|
include com.gargoylesoftware.htmlunit.ConfirmHandler
|
@@ -16,9 +18,12 @@ module Celerity
|
|
16
18
|
@webclient = webclient
|
17
19
|
@procs = Hash.new { |h, k| h[k] = [] }
|
18
20
|
end
|
19
|
-
|
21
|
+
|
22
|
+
#
|
20
23
|
# Add a listener block for one of the available types.
|
21
24
|
# @see Celerity::Browser#add_listener
|
25
|
+
#
|
26
|
+
|
22
27
|
def add_listener(type, &block)
|
23
28
|
case type
|
24
29
|
when :status
|
@@ -58,46 +63,70 @@ module Celerity
|
|
58
63
|
raise TypeError, "must give proc or index"
|
59
64
|
end
|
60
65
|
end
|
61
|
-
|
66
|
+
|
67
|
+
#
|
62
68
|
# interface StatusHandler
|
69
|
+
#
|
70
|
+
|
63
71
|
def statusMessageChanged(page, message)
|
64
72
|
@procs[:status].each { |h| h.call(page, message) }
|
65
73
|
end
|
66
|
-
|
74
|
+
|
75
|
+
#
|
67
76
|
# interface AlertHandler
|
77
|
+
#
|
78
|
+
|
68
79
|
def handleAlert(page, message)
|
69
80
|
@procs[:alert].each { |h| h.call(page, message) }
|
70
81
|
end
|
71
|
-
|
82
|
+
|
83
|
+
#
|
72
84
|
# interface ConfirmHandler
|
85
|
+
#
|
86
|
+
|
73
87
|
def handleConfirm(page, message)
|
74
88
|
@procs[:confirm].each { |h| h.call(page, message) }
|
75
89
|
end
|
76
90
|
|
91
|
+
#
|
77
92
|
# interface AttachmentHandler
|
93
|
+
#
|
94
|
+
|
78
95
|
def handleAttachment(page)
|
79
96
|
@procs[:attachment].each { |h| h.call(page) }
|
80
97
|
end
|
81
|
-
|
98
|
+
|
99
|
+
#
|
82
100
|
# interface PromptHandler
|
101
|
+
#
|
102
|
+
|
83
103
|
def handlePrompt(page, message)
|
84
104
|
@procs[:prompt].each { |h| h.call(page, message) }
|
85
105
|
end
|
86
|
-
|
106
|
+
|
107
|
+
#
|
87
108
|
# interface WebWindowListener
|
109
|
+
#
|
110
|
+
|
88
111
|
def webWindowClosed(web_window_event)
|
89
112
|
@procs[:web_window_event].each { |h| h.call(web_window_event) }
|
90
113
|
end
|
91
114
|
alias_method :webWindowOpened, :webWindowClosed
|
92
115
|
alias_method :webWindowContentChanged, :webWindowClosed
|
93
116
|
|
117
|
+
#
|
94
118
|
# interface HTMLParserListener
|
119
|
+
#
|
120
|
+
|
95
121
|
def error(message, url, line, column, key)
|
96
122
|
@procs[:html_parser].each { |h| h.call(message, url, line, column, key) }
|
97
123
|
end
|
98
124
|
alias_method :warning, :error
|
99
125
|
|
126
|
+
#
|
100
127
|
# interface IncorrectnessListener
|
128
|
+
#
|
129
|
+
|
101
130
|
def notify(message, origin)
|
102
131
|
@procs[:incorrectness].each { |h| h.call(message, origin) }
|
103
132
|
end
|
data/lib/celerity/util.rb
CHANGED
@@ -51,8 +51,11 @@ module Celerity
|
|
51
51
|
HtmlUnit2CelerityElement[klass]
|
52
52
|
end
|
53
53
|
|
54
|
+
#
|
54
55
|
# HtmlUnit will recognize most common file types, but custom ones can be added here.
|
55
56
|
# Used for FileField uploads.
|
57
|
+
#
|
58
|
+
|
56
59
|
ContentTypes = {
|
57
60
|
".bmp" => "image/x-ms-bmp",
|
58
61
|
".doc" => "application/msword",
|