From c621e651c9ba45bb4be06f32677321fc74b49175 Mon Sep 17 00:00:00 2001 From: Matthew Mongeau Date: Fri, 22 Jul 2011 15:21:17 -0400 Subject: [PATCH] Support Textareas#value --- spec/integration/session_spec.rb | 10 +++++----- src/capybara.js | 12 +++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/spec/integration/session_spec.rb b/spec/integration/session_spec.rb index b3e6cad..4602af4 100644 --- a/spec/integration/session_spec.rb +++ b/spec/integration/session_spec.rb @@ -86,11 +86,11 @@ describe Capybara::Session, "with TestApp" do @session = Capybara::Session.new(:reusable_webkit, TestApp) end - def extract_results(session) - YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.text - end + # def extract_results(session) + # YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.text + # end - it_should_behave_like 'attach_file' - # it_should_behave_like "session" + # it_should_behave_like 'attach_file' + it_should_behave_like "session" # it_should_behave_like "session with javascript support" end diff --git a/src/capybara.js b/src/capybara.js index 84c0d7e..05788ff 100644 --- a/src/capybara.js +++ b/src/capybara.js @@ -28,16 +28,22 @@ Capybara = { }, text: function (index) { - return this.nodes[index].innerText; + var node = this.nodes[index]; + var type = (node.type || node.tagName).toLowerCase(); + if (type == "textarea") { + return node.innerHTML; + } else { + return node.innerText; + } }, attribute: function (index, name) { switch(name) { - case 'checked': + case 'checked': return this.nodes[index].checked; break; - case 'disabled': + case 'disabled': return this.nodes[index].disabled; break;