diff --git a/lib/webcat/culerity_driver.rb b/lib/webcat/culerity_driver.rb index 92aa3725..61b844c0 100644 --- a/lib/webcat/culerity_driver.rb +++ b/lib/webcat/culerity_driver.rb @@ -20,6 +20,12 @@ class Webcat::Driver::Culerity def click node.click end + + def tag_name + # FIXME: this might be the dumbest way ever of getting the tag name + # there has to be something better... + node.to_xml[/^\s*<([a-z0-9\-\:]+)/, 1] + end end attr_reader :app, :rack_server diff --git a/lib/webcat/rack_test_driver.rb b/lib/webcat/rack_test_driver.rb index 85d68fcf..6932ab44 100644 --- a/lib/webcat/rack_test_driver.rb +++ b/lib/webcat/rack_test_driver.rb @@ -15,6 +15,10 @@ class Webcat::Driver::RackTest def click session.visit(attribute(:href)) end + + def tag_name + node.node_name + end end include ::Rack::Test::Methods diff --git a/spec/drivers_spec.rb b/spec/drivers_spec.rb index 8407ff1b..f35d5960 100644 --- a/spec/drivers_spec.rb +++ b/spec/drivers_spec.rb @@ -45,6 +45,12 @@ shared_examples_for 'driver' do @driver.find('//a')[1].attribute(:id).should == 'foo' @driver.find('//a')[1].attribute(:rel).should be_nil end + + it "should extract node tag name" do + @driver.find('//a')[0].tag_name.should == 'a' + @driver.find('//a')[1].tag_name.should == 'a' + @driver.find('//p')[1].tag_name.should == 'p' + end end end