jarib-celerity 0.0.6.6 → 0.0.6.7
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.
- data/lib/celerity/browser.rb +1 -1
- data/lib/celerity/element.rb +6 -3
- data/lib/celerity/elements/option.rb +1 -1
- data/lib/celerity/elements/select_list.rb +13 -12
- data/lib/celerity/elements/text_field.rb +1 -0
- data/lib/celerity/htmlunit.rb +1 -1
- data/lib/celerity/util.rb +0 -1
- data/lib/celerity/version.rb +1 -1
- metadata +2 -2
data/lib/celerity/browser.rb
CHANGED
data/lib/celerity/element.rb
CHANGED
@@ -8,7 +8,7 @@ module Celerity
|
|
8
8
|
include Exception
|
9
9
|
include Container
|
10
10
|
|
11
|
-
attr_reader :container
|
11
|
+
attr_reader :container
|
12
12
|
|
13
13
|
# number of spaces that separate the property from the value in the create_string method
|
14
14
|
TO_S_SIZE = 14
|
@@ -97,6 +97,10 @@ module Celerity
|
|
97
97
|
def locate
|
98
98
|
@object = ElementLocator.new(@container, self.class).find_by_conditions(@conditions)
|
99
99
|
end
|
100
|
+
|
101
|
+
def object
|
102
|
+
@object || locate
|
103
|
+
end
|
100
104
|
|
101
105
|
#
|
102
106
|
# @return [String] A string representation of the element.
|
@@ -233,10 +237,9 @@ module Celerity
|
|
233
237
|
|
234
238
|
meth = selector_to_attribute(meth)
|
235
239
|
|
236
|
-
if self.class::ATTRIBUTES.include?(meth)
|
240
|
+
if self.class::ATTRIBUTES.include?(meth) || (self.class == Element && @object.hasAttribute(meth.to_s))
|
237
241
|
return @object.getAttribute(meth.to_s)
|
238
242
|
end
|
239
|
-
|
240
243
|
Log.warn "Element\#method_missing calling super with #{meth.inspect}"
|
241
244
|
super
|
242
245
|
end
|
@@ -10,7 +10,7 @@ module Celerity
|
|
10
10
|
def options
|
11
11
|
assert_exists
|
12
12
|
@object.getOptions.map do |e|
|
13
|
-
e.asText.empty? ? e.
|
13
|
+
e.asText.empty? ? e.getLabelAttribute : e.asText
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -20,7 +20,7 @@ module Celerity
|
|
20
20
|
|
21
21
|
def selected_options
|
22
22
|
assert_exists
|
23
|
-
@object.getSelectedOptions.map { |e| e.asText.empty? ? e.
|
23
|
+
@object.getSelectedOptions.map { |e| e.asText.empty? ? e.getLabelAttribute : e.asText }
|
24
24
|
end
|
25
25
|
|
26
26
|
#
|
@@ -48,11 +48,9 @@ module Celerity
|
|
48
48
|
raise NoValueFoundException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}" unless include?(value)
|
49
49
|
|
50
50
|
selected = nil
|
51
|
-
matching = @object.getOptions.select do |
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
matching.each do |option|
|
51
|
+
matching = @object.getOptions.select do |option|
|
52
|
+
next unless matches_option?(option, value)
|
53
|
+
|
56
54
|
selected ||= option.asText
|
57
55
|
@container.update_page option.click
|
58
56
|
end
|
@@ -70,7 +68,7 @@ module Celerity
|
|
70
68
|
|
71
69
|
def include?(value)
|
72
70
|
assert_exists
|
73
|
-
!!@object.getOptions.find { |e|
|
71
|
+
!!@object.getOptions.find { |e| matches_option?(e, value) }
|
74
72
|
end
|
75
73
|
|
76
74
|
#
|
@@ -84,7 +82,7 @@ module Celerity
|
|
84
82
|
def selected?(value)
|
85
83
|
assert_exists
|
86
84
|
raise UnknownObjectException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}" unless include?(value)
|
87
|
-
!!@object.getOptions.find { |e|
|
85
|
+
!!@object.getOptions.find { |e| matches_option?(e, value) && e.isSelected }
|
88
86
|
end
|
89
87
|
|
90
88
|
#
|
@@ -92,7 +90,6 @@ module Celerity
|
|
92
90
|
# defined, otherwise 'select-one'.
|
93
91
|
#
|
94
92
|
# @return [String]
|
95
|
-
# TODO: Move to watir_compatibility or delete it 2008-05-23 Alexander
|
96
93
|
#
|
97
94
|
|
98
95
|
def type
|
@@ -109,12 +106,16 @@ module Celerity
|
|
109
106
|
|
110
107
|
def value
|
111
108
|
assert_exists
|
112
|
-
if (
|
113
|
-
|
109
|
+
if (option = @object.getSelectedOptions.to_a.first)
|
110
|
+
option.getValueAttribute
|
114
111
|
end
|
115
112
|
end
|
116
113
|
|
117
114
|
private
|
118
115
|
|
116
|
+
def matches_option?(option, value)
|
117
|
+
matches?(option.asText, value) || (option.hasAttribute("label") && matches?(option.getLabelAttribute, value))
|
118
|
+
end
|
119
|
+
|
119
120
|
end # SelectList
|
120
121
|
end # Celerity
|
data/lib/celerity/htmlunit.rb
CHANGED
@@ -39,6 +39,6 @@ end unless Java::JavaLang::Iterable < Enumerable # depends on JRuby version
|
|
39
39
|
|
40
40
|
class Java::ComGargoylesoftwareHtmlunitHtml::HtmlPage
|
41
41
|
def inspect
|
42
|
-
'#<HtmlPage:0x%s(%s)>' % [self.hash.to_s(16), getWebResponse.
|
42
|
+
'#<HtmlPage:0x%s(%s)>' % [self.hash.to_s(16), getWebResponse.getRequestUrl.toString]
|
43
43
|
end
|
44
44
|
end
|
data/lib/celerity/util.rb
CHANGED
@@ -28,7 +28,6 @@ module Celerity
|
|
28
28
|
HtmlUnit::Html::HtmlHiddenInput => Celerity::Hidden,
|
29
29
|
HtmlUnit::Html::HtmlImage => Celerity::Image,
|
30
30
|
HtmlUnit::Html::HtmlLabel => Celerity::Label,
|
31
|
-
HtmlUnit::Html::HtmlLink => Celerity::Link,
|
32
31
|
HtmlUnit::Html::HtmlListItem => Celerity::Li,
|
33
32
|
HtmlUnit::Html::HtmlMap => Celerity::Map,
|
34
33
|
HtmlUnit::Html::HtmlOption => Celerity::Option,
|
data/lib/celerity/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jarib-celerity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.6.
|
4
|
+
version: 0.0.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-04-
|
14
|
+
date: 2009-04-30 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|