Better implementation of attributes for celerity, closes #206

This commit is contained in:
Jonas Nicklas 2010-11-21 19:00:28 +01:00
parent 6fa8a5652c
commit b022ca9926
2 changed files with 3 additions and 6 deletions

View File

@ -5,11 +5,7 @@ class Capybara::Driver::Celerity < Capybara::Driver::Base
end end
def [](name) def [](name)
value = if name.to_sym == :class value = native.attribute_value(name.to_sym)
native.class_name
else
native.send(name.to_sym)
end
return value if value and not value.to_s.empty? return value if value and not value.to_s.empty?
end end
@ -17,7 +13,7 @@ class Capybara::Driver::Celerity < Capybara::Driver::Base
if tag_name == "select" and native.multiple? if tag_name == "select" and native.multiple?
find(".//option[@selected]").map { |n| n.value || n.text } find(".//option[@selected]").map { |n| n.value || n.text }
else else
self[:value] native.value
end end
end end

View File

@ -42,6 +42,7 @@ shared_examples_for 'driver' do
it "should extract node attributes" do it "should extract node attributes" do
@driver.find('//a')[0][:class].should == 'simple' @driver.find('//a')[0][:class].should == 'simple'
@driver.find('//a')[1][:id].should == 'foo' @driver.find('//a')[1][:id].should == 'foo'
@driver.find('//input')[0][:type].should == 'text'
end end
it "should extract boolean node attributes" do it "should extract boolean node attributes" do