Work around form fields overriding form element methods - Issue #1010

This commit is contained in:
Thomas Walpole 2017-06-02 11:35:08 -07:00
parent da13973bae
commit 562522acf1
2 changed files with 29 additions and 1 deletions

View File

@ -337,6 +337,33 @@ describe Capybara::Session do
end
end
context "text" do
before(:all) do
@app = Class.new(ExampleApp) do
get "/" do
<<-HTML
<!DOCTYPE html>
<html>
<head></head>
<body>
<form>
This is my form
<input name="type"/>
<input name="tagName"/>
</form>
</body>
</html>
HTML
end
end
end
it "gets a forms text when inputs have conflicting names" do
subject.visit("/")
expect(subject.find(:css, "form").text).to eq("This is my form")
end
end
context 'click tests' do
before(:all) do
@app = Class.new(ExampleApp) do

View File

@ -66,7 +66,8 @@ Capybara = {
text: function (index) {
var node = this.getNode(index);
var type = (node.type || node.tagName).toLowerCase();
var type = node instanceof HTMLFormElement ? 'form' : (node.type || node.tagName).toLowerCase();
if (!this.isNodeVisible(node)) {
return '';
} else if (type == "textarea") {