Workaround selenium issues with editing content editable children
This commit is contained in:
parent
7e5a1f77a6
commit
43cc72d3e6
|
@ -76,10 +76,6 @@ matrix:
|
|||
- rvm: 2.4.0
|
||||
- rvm: rbx-3
|
||||
- rvm: jruby-9.1.7.0
|
||||
- env: CAPYBARA_MARIONETTE=true
|
||||
- env:
|
||||
- WINDOW_TEST=true
|
||||
- CAPYBARA_MARIONETTE=true
|
||||
before_install:
|
||||
- mkdir -p ~/drivers; export PATH=~/drivers:$PATH;
|
||||
- if [ $CAPYBARA_CHROME ]; then
|
||||
|
|
|
@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|||
s.add_runtime_dependency("xpath", ["~> 2.0"])
|
||||
s.add_runtime_dependency("addressable")
|
||||
|
||||
s.add_development_dependency("selenium-webdriver", [">= 2.0", "< 4.0"])
|
||||
s.add_development_dependency("selenium-webdriver", [">= 2.0", "< 3.3"])
|
||||
s.add_development_dependency("sinatra", [">= 0.9.4"])
|
||||
s.add_development_dependency("rspec", [">= 2.2.0"])
|
||||
s.add_development_dependency("launchy", [">= 2.0.4"])
|
||||
|
|
|
@ -76,14 +76,23 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
|
|||
end
|
||||
elsif native.attribute('isContentEditable')
|
||||
#ensure we are focused on the element
|
||||
native.click
|
||||
script = <<-JS
|
||||
var range = document.createRange();
|
||||
arguments[0].focus();
|
||||
range.selectNodeContents(arguments[0]);
|
||||
window.getSelection().addRange(range);
|
||||
JS
|
||||
driver.browser.execute_script script, native
|
||||
native.send_keys(value.to_s)
|
||||
driver.execute_script script, native
|
||||
if (driver.options[:browser].to_s == "chrome") ||
|
||||
(driver.options[:browser].to_s == "firefox" && !driver.marionette?)
|
||||
# chromedriver raises a can't focus element if we use native.send_keys
|
||||
# we've already focused it so just use action api
|
||||
driver.browser.action.send_keys(value.to_s).perform
|
||||
else
|
||||
# action api is really slow here just use native.send_keys
|
||||
native.send_keys(value.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -135,10 +135,11 @@ Capybara::SpecHelper.spec "node" do
|
|||
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" if @session.respond_to?(:mode) && @session.mode.to_s =~ /^selenium_/
|
||||
# pending "Selenium doesn't like editing nested contents" if @session.respond_to?(:mode) && @session.mode.to_s =~ /^selenium_/
|
||||
@session.visit('/with_js')
|
||||
@session.find(:css,'#existing_content_editable_child').set('WYSIWYG')
|
||||
expect(@session.find(:css,'#existing_content_editable_child').text).to eq('WYSIWYG')
|
||||
expect(@session.find(:css,'#existing_content_editable_child_parent').text).to eq('Some content WYSIWYG')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
<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 contenteditable='true' id='existing_content_editable_child_parent' style='height: 1em;'>
|
||||
Some content
|
||||
<div id='existing_content_editable_child' style='height: 1em;'>Content</div>
|
||||
</div>
|
||||
</p>
|
||||
|
|
Loading…
Reference in New Issue