Permalink
Browse files

ensure that the content editable element has focus by selecting an em…

…pty selection
  • Loading branch information...
JonRowe committed Mar 5, 2013
1 parent 28661ba commit 41b46253d3dfd75e5f9afc484bcd1d1d024ed3e8
Showing with 7 additions and 0 deletions.
  1. +7 −0 lib/capybara/selenium/node.rb
@@ -39,6 +39,13 @@ def set(value)
#workaround for selenium raising an ElementNotVisible on empty elements
driver.browser.execute_script "arguments[0].innerHTML = ' '", native
end
+ #ensure we are focused on the element
+ script = <<-JS
+ var range = document.createRange();
+ range.setStart(arguments[0].childNodes[0], 0);
+ window.getSelection().addRange(range);
+ JS
+ driver.browser.execute_script script, native
native.clear
native.send_keys(value.to_s)
end

0 comments on commit 41b4625

Please sign in to comment.