lib/watir-classic/element.rb in watir-classic-4.0.1 vs lib/watir-classic/element.rb in watir-classic-4.1.0
- old
+ new
@@ -86,19 +86,29 @@
# @return {Element} element casted into specific sub-class of Element.
# @macro exists
def to_subtype
assert_exists
- tag = tag_name
+ tag = tag_name.downcase
if tag == "html"
element(:ole_object => ole_object)
elsif tag == "input"
- send(ole_object.invoke('type'), :ole_object => ole_object)
- elsif tag == "select"
- select_list(:ole_object => ole_object)
- elsif respond_to?(tag.downcase)
- send(tag.downcase, :ole_object => ole_object)
+ input_type = case ole_object.invoke("type")
+ when *%w[button reset submit image]
+ "button"
+ when "checkbox"
+ "checkbox"
+ when "radio"
+ "radio"
+ when "file"
+ "file_field"
+ else
+ "text_field"
+ end
+ send(input_type, :ole_object => ole_object)
+ elsif respond_to?(tag)
+ send(tag, :ole_object => ole_object)
else
self
end
end
@@ -111,11 +121,11 @@
focus
page_container.send_keys *keys
end
# Retrieve element's css style.
- # @param [String] property When property is specified then only css for that property is returned.
+ # @param [String] property When property is specified then only css for that property is returned.
# @return [String] css style as a one long String.
# @return [String] css style for specified property if property parameter is specified.
# @macro exists
def style(property=nil)
assert_exists
@@ -247,11 +257,11 @@
# When any parent element is not also visible then the current element is determined as not visible too.
# @return [Boolean] true if element is visible, false otherwise.
# @macro exists
def visible?
# Now iterate up the DOM element tree and return false if any
- # parent element isn't visible
+ # parent element isn't visible
assert_exists
visible_child = false
object = @o
while object
begin
@@ -294,21 +304,21 @@
if meth =~ /(.*)_no_wait/ && self.respond_to?($1)
perform_action do
ruby_code = generate_ruby_code(self, $1, *args)
system(spawned_no_wait_command(ruby_code))
end
- elsif meth =~ /^data_(.*)/
+ elsif meth =~ /^(aria|data)_(.+)$/
self.send(:attribute_value, meth.gsub("_", "-")) || ''
else
super
end
end
# @private
def locate
@o = @container.locator_for(TaggedElementLocator, @specifiers, self.class).locate
- end
+ end
# @private
def __ole_inner_elements
assert_exists
ole_object.all
@@ -438,11 +448,11 @@
end
def build_method(method_name, *args)
arguments = args.map do |argument|
if argument.is_a?(String)
- argument = "'#{argument}'"
+ argument = "'#{argument}'"
else
argument = argument.inspect
end
end
"#{replace_method(method_name)}(#{arguments.join(',')})"
@@ -478,6 +488,6 @@
ensure
clear_highlight
end
end
-end
+end