Skip to content

Commit

Permalink
Node#value crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Morrison committed Feb 26, 2011
1 parent b9ecd40 commit ef3122a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/capybara/driver/webkit/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions spec/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/capybara.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.