From ba3f0b1a183669d6738ba1d2eedf5332e1249136 Mon Sep 17 00:00:00 2001 From: Jason Morrison Date: Sat, 26 Feb 2011 14:55:40 -0500 Subject: [PATCH] Fetch a node's tag name --- lib/capybara/driver/webkit/node.rb | 2 +- spec/driver_spec.rb | 5 ++++- src/capybara.js | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/capybara/driver/webkit/node.rb b/lib/capybara/driver/webkit/node.rb index 386dfe9..785709e 100644 --- a/lib/capybara/driver/webkit/node.rb +++ b/lib/capybara/driver/webkit/node.rb @@ -33,7 +33,7 @@ class Capybara::Driver::Webkit end def tag_name - raise NotImplementedError + invoke "tagName" end def visible? diff --git a/spec/driver_spec.rb b/spec/driver_spec.rb index c8d0bfb..121d0eb 100644 --- a/spec/driver_spec.rb +++ b/spec/driver_spec.rb @@ -125,5 +125,8 @@ describe Capybara::Driver::Webkit do expect { subject.execute_script(%) }. to raise_error(Capybara::Driver::Webkit::WebkitError) end -end + it "returns a node's tag name" do + subject.find("//p").first.tag_name.should == "P" + end +end diff --git a/src/capybara.js b/src/capybara.js index f9e07a8..865db39 100644 --- a/src/capybara.js +++ b/src/capybara.js @@ -24,6 +24,10 @@ Capybara = { attribute: function (index, name) { return this.nodes[index].getAttribute(name); + }, + + tagName: function(index) { + return this.nodes[index].tagName; } };