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
|
describe Capybara::Webkit, 'compatibility with selenium' do
|
||||||
include AppRunner
|
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)
|
run_application_for_html(<<-HTML)
|
||||||
<html><body>
|
<html><body>
|
||||||
<form onsubmit="return false">
|
<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_windows => !(RbConfig::CONFIG['host_os'] =~ /mingw32/).nil?
|
||||||
c.filter_run_excluding :skip_on_jruby => !defined?(::JRUBY_VERSION).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 can't support outerWidth and outerHeight without a visible window.
|
||||||
# We focus the next window instead of failing when closing windows.
|
# 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"];
|
textTypes = ["email", "number", "password", "search", "tel", "text", "textarea", "url"];
|
||||||
|
|
||||||
if (textTypes.indexOf(type) != -1) {
|
if (textTypes.indexOf(type) != -1) {
|
||||||
this.focus(index);
|
|
||||||
|
|
||||||
maxLength = this.attribute(index, "maxlength");
|
maxLength = this.attribute(index, "maxlength");
|
||||||
if (maxLength && value.length > maxLength) {
|
if (maxLength && value.length > maxLength) {
|
||||||
length = maxLength;
|
length = maxLength;
|
||||||
|
@ -281,7 +279,9 @@ Capybara = {
|
||||||
length = value.length;
|
length = value.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!node.readOnly)
|
if (!node.readOnly) {
|
||||||
|
this.focus(index);
|
||||||
|
|
||||||
node.value = "";
|
node.value = "";
|
||||||
|
|
||||||
for (strindex = 0; strindex < length; strindex++) {
|
for (strindex = 0; strindex < length; strindex++) {
|
||||||
|
@ -290,6 +290,7 @@ Capybara = {
|
||||||
|
|
||||||
if (value == '')
|
if (value == '')
|
||||||
this.trigger(index, "change");
|
this.trigger(index, "change");
|
||||||
|
}
|
||||||
} else if (type === "checkbox" || type === "radio") {
|
} else if (type === "checkbox" || type === "radio") {
|
||||||
if (node.checked != (value === "true")) {
|
if (node.checked != (value === "true")) {
|
||||||
this.leftClick(index);
|
this.leftClick(index);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue