mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Return html inside textareas when page is loaded. Closes #1025
This commit is contained in:
parent
af85687487
commit
ca4781f186
5 changed files with 9 additions and 4 deletions
|
@ -74,7 +74,7 @@ module Capybara
|
|||
#
|
||||
def value
|
||||
if tag_name == 'textarea'
|
||||
native.content.sub(/\A\n/, '')
|
||||
native.inner_html.sub(/\A\n/, '')
|
||||
elsif tag_name == 'select'
|
||||
if native['multiple'] == 'multiple'
|
||||
native.xpath(".//option[@selected='selected']").map { |option| option[:value] || option.content }
|
||||
|
|
|
@ -60,7 +60,7 @@ class Capybara::RackTest::Form < Capybara::RackTest::Node
|
|||
merge_param!(params, field['name'].to_s, (option['value'] || option.text).to_s) if option
|
||||
end
|
||||
when 'textarea'
|
||||
merge_param!(params, field['name'].to_s, field.text.to_s)
|
||||
merge_param!(params, field['name'].to_s, field.inner_html.to_s)
|
||||
end
|
||||
end
|
||||
merge_param!(params, button[:name], button[:value] || "") if button[:name]
|
||||
|
|
|
@ -27,7 +27,7 @@ class Capybara::RackTest::Node < Capybara::Driver::Node
|
|||
elsif input_field?
|
||||
set_input(value)
|
||||
elsif textarea?
|
||||
native.content = value.to_s unless self[:readonly]
|
||||
native.inner_html = value.to_s unless self[:readonly]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -58,10 +58,14 @@ Capybara::SpecHelper.spec "node" do
|
|||
@session.find('//textarea[@id="additional_newline"]').value.should == "\nbanana"
|
||||
end
|
||||
|
||||
it "return any HTML content in textarea" do
|
||||
it "return any HTML content added to textarea" do
|
||||
@session.find('//textarea[1]').set("some <em>html</em> here")
|
||||
@session.find('//textarea[1]').value.should == "some <em>html</em> here"
|
||||
end
|
||||
|
||||
it "return any HTML content in textarea", :focus => true do
|
||||
@session.find(:css, 'textarea#with-html').value.should == "contains <em>html</em>"
|
||||
end
|
||||
end
|
||||
|
||||
describe "#set" do
|
||||
|
|
|
@ -35,6 +35,7 @@ banana</textarea>
|
|||
|
||||
banana</textarea>
|
||||
<textarea readonly="readonly">textarea should not change</textarea>
|
||||
<textarea id="with-html">contains <em>html</em></textarea>
|
||||
<a href="/redirect_back">BackToMyself</a>
|
||||
<a title="twas a fine link" href="/redirect">A link came first</a>
|
||||
<a title="a fine link" href="/with_simple_html">A link</a>
|
||||
|
|
Loading…
Reference in a new issue