mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Don't interact with readonly elements
* This behavior changed in Capybara 2.4. * Previously we would focus and send keypress events to readonly elements. Now readonly elements are ignored, and a warning is emitted by Capybara.
This commit is contained in:
parent
5b43f53790
commit
bbcfb7ea4b
3 changed files with 11 additions and 9 deletions
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
describe Capybara::Webkit, 'compatibility with selenium' do
|
||||
include AppRunner
|
||||
|
||||
it 'generates the same events as selenium when filling out forms' do
|
||||
it 'generates the same events as selenium when filling out forms', selenium_compatibility: true do
|
||||
run_application_for_html(<<-HTML)
|
||||
<html><body>
|
||||
<form onsubmit="return false">
|
||||
|
|
|
@ -28,6 +28,7 @@ RSpec.configure do |c|
|
|||
|
||||
c.filter_run_excluding :skip_on_windows => !(RbConfig::CONFIG['host_os'] =~ /mingw32/).nil?
|
||||
c.filter_run_excluding :skip_on_jruby => !defined?(::JRUBY_VERSION).nil?
|
||||
c.filter_run_excluding :selenium_compatibility => (Capybara::VERSION =~ /^2\.4\./).nil?
|
||||
|
||||
# We can't support outerWidth and outerHeight without a visible window.
|
||||
# We focus the next window instead of failing when closing windows.
|
||||
|
|
|
@ -272,8 +272,6 @@ Capybara = {
|
|||
textTypes = ["email", "number", "password", "search", "tel", "text", "textarea", "url"];
|
||||
|
||||
if (textTypes.indexOf(type) != -1) {
|
||||
this.focus(index);
|
||||
|
||||
maxLength = this.attribute(index, "maxlength");
|
||||
if (maxLength && value.length > maxLength) {
|
||||
length = maxLength;
|
||||
|
@ -281,15 +279,18 @@ Capybara = {
|
|||
length = value.length;
|
||||
}
|
||||
|
||||
if (!node.readOnly)
|
||||
if (!node.readOnly) {
|
||||
this.focus(index);
|
||||
|
||||
node.value = "";
|
||||
|
||||
for (strindex = 0; strindex < length; strindex++) {
|
||||
CapybaraInvocation.keypress(value[strindex]);
|
||||
}
|
||||
for (strindex = 0; strindex < length; strindex++) {
|
||||
CapybaraInvocation.keypress(value[strindex]);
|
||||
}
|
||||
|
||||
if (value == '')
|
||||
this.trigger(index, "change");
|
||||
if (value == '')
|
||||
this.trigger(index, "change");
|
||||
}
|
||||
} else if (type === "checkbox" || type === "radio") {
|
||||
if (node.checked != (value === "true")) {
|
||||
this.leftClick(index);
|
||||
|
|
Loading…
Reference in a new issue