Skip to content
Browse files

extra test for nested content

  • Loading branch information...
1 parent c91cc20 commit 352a904e4b60aff74bbb5611163d7e61c50acebe @JonRowe committed Mar 22, 2013
Showing with 11 additions and 2 deletions.
  1. +1 −2 lib/capybara/selenium/node.rb
  2. +7 −0 lib/capybara/spec/session/node_spec.rb
  3. +3 −0 lib/capybara/spec/views/with_js.erb
View
3 lib/capybara/selenium/node.rb
@@ -38,11 +38,10 @@ def set(value)
#ensure we are focused on the element
script = <<-JS
var range = document.createRange();
- range.setStart(arguments[0], 0);
+ range.selectNodeContents(arguments[0]);
window.getSelection().addRange(range);
JS
driver.browser.execute_script script, native
- native.clear
native.send_keys(value.to_s)
end
end
View
7 lib/capybara/spec/session/node_spec.rb
@@ -83,6 +83,13 @@
@session.find(:css,'#blank_content_editable').set('WYSIWYG')
@session.find(:css,'#blank_content_editable').text.should == 'WYSIWYG'
end
+
+ it 'should allow me to change the contents of a contenteditable elements child', :requires => [:js] do
+ pending "Selenium doesn't like editing nested contents"
+ @session.visit('/with_js')
+ @session.find(:css,'#existing_content_editable_child').set('WYSIWYG')
+ @session.find(:css,'#existing_content_editable_child').text.should == 'WYSIWYG'
+ end
end
describe "#tag_name" do
View
3 lib/capybara/spec/views/with_js.erb
@@ -38,6 +38,9 @@
<p>
<div contenteditable='true' id='existing_content_editable'>Editable content</div>
<div contenteditable='true' id='blank_content_editable' style='height: 1em;'></div>
+ <div contenteditable='true' style='height: 1em;'>
+ <div id='existing_content_editable_child' style='height: 1em;'>Content</div>
+ </div>
</p>
<p>

0 comments on commit 352a904

Please sign in to comment.
Something went wrong with that request. Please try again.