Permalink
Browse files

Node#value crashes

  • Loading branch information...
jasonm committed Feb 26, 2011
1 parent b9ecd40 commit ef3122a26d29ff5a721657fac2f5f1aef6c26585
Showing with 31 additions and 1 deletion.
  1. +16 −1 lib/capybara/driver/webkit/node.rb
  2. +10 −0 spec/driver_spec.rb
  3. +5 −0 src/capybara.js
@@ -9,13 +9,28 @@ def [](name)
end
def value
- raise NotImplementedError
+ invoke "value"
end
def set(value)
raise NotImplementedError
end
+ # akephalos
+ # def set(value)
+ # if tag_name == 'textarea'
+ # node.value = value.to_s
+ # elsif tag_name == 'input' and type == 'radio'
+ # click
+ # elsif tag_name == 'input' and type == 'checkbox'
+ # if value != self['checked']
+ # click
+ # end
+ # elsif tag_name == 'input'
+ # node.value = value.to_s
+ # end
+ # end
+
def select_option
raise NotImplementedError
end
View
@@ -9,6 +9,9 @@
<script type="text/javascript">
document.write("<p id='greeting'>he" + "llo</p>");
</script>
+ <form action="/" method="GET">
+ <textarea id="only-textarea">what a wonderful area for text</textarea>
+ </form>
</body></html>
HTML
[200,
@@ -58,6 +61,9 @@
<script type="text/javascript">
document.write("<p id='greeting'>he" + "llo</p>");
</script><p id="greeting">hello</p>
+ <form action="/" method="GET">
+ <textarea id="only-textarea">what a wonderful area for text</textarea>
+ </form>
</body></html>}
end
@@ -129,4 +135,8 @@
it "returns a node's tag name" do
subject.find("//p").first.tag_name.should == "p"
end
+
+ it "fetches the value of a textarea" do
+ subject.find("//textarea").first.value.should == "what a wonderful area for text"
+ end
end
View
@@ -28,6 +28,11 @@ Capybara = {
tagName: function(index) {
return this.nodes[index].tagName.toLowerCase();
+ },
+
+ value: function(index) {
+ return this.nodes[index].value;
}
+
};

0 comments on commit ef3122a

Please sign in to comment.