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.
@@ -775,7 +775,7 @@ module Celerity
775
775
  if element_class = Celerity::Util.htmlunit2celerity(obj.class)
776
776
  element_class.new(self, :object, obj)
777
777
  else
778
- Element.new(self, :object, nil)
778
+ Element.new(self, :object, obj)
779
779
  end
780
780
  end
781
781
 
@@ -8,7 +8,7 @@ module Celerity
8
8
  include Exception
9
9
  include Container
10
10
 
11
- attr_reader :container, :object
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
@@ -26,7 +26,7 @@ module Celerity
26
26
  def label
27
27
  # overrides Container#label
28
28
  assert_exists
29
- @object.getAttribute("label")
29
+ @object.getLabelAttribute
30
30
  end
31
31
  end
32
32
  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.getAttribute("label") : e.asText
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.getAttribute('label') : e.asText }
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 |e|
52
- matches?(e.asText, value) || matches?(e.getAttribute('label'), value)
53
- end
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| matches?(e.asText, value) || matches?(e.getAttribute('label'), value) }
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| matches?(e.asText, value) && e.isSelected }
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 (optn = @object.getSelectedOptions.to_a.first)
113
- optn.getValueAttribute
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
@@ -14,6 +14,7 @@ module Celerity
14
14
  DEFAULT_HOW = :name
15
15
 
16
16
  def visible?
17
+ assert_exists
17
18
  type == 'hidden' ? false : super
18
19
  end
19
20
 
@@ -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.getUrl.toString]
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,
@@ -3,7 +3,7 @@ module Celerity #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
5
  TINY = 6
6
- PATCH = 6 # Set to nil for official release
6
+ PATCH = 7 # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
9
9
  end
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.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-22 00:00:00 -07:00
14
+ date: 2009-04-30 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency