Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixing handling of input type="email" fields #206

Closed
wants to merge 2 commits into from

3 participants

@jkrall

This closes #46. (and #106 as well, tho I previously sent a pull request for that issue that contained a bunch of other unrelated crap in it, and it never got merged)

@jferris jferris commented on the diff
lib/capybara/driver/webkit/browser.rb
@@ -110,7 +110,7 @@ class Capybara::Driver::Webkit
end
def check
- result = @socket.gets.strip
+ result = @socket.gets.to_s.strip
@jferris Owner
jferris added a note

Is there a test for this change?

@jkrall
jkrall added a note

Nope, actually that one snuck into this commit by accident. Sorry about that.

I'll fix it if you want... but honestly, this commit is really straightforward. If you don't want to pull this b/c of the .to_s ... that's fine, but you should really consider just adding the email field check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jferris
Owner

Thanks; I just merged it without that one change.

@jferris jferris closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 13, 2011
  1. @jkrall
  2. @jkrall

    Adding test for email form inputs

    jkrall authored
    ALSO:  added simple .to_s to fix issue #66
This page is out of date. Refresh to see the latest.
View
2  lib/capybara/driver/webkit/browser.rb
@@ -110,7 +110,7 @@ def attempt_connect
end
def check
- result = @socket.gets.strip
+ result = @socket.gets.to_s.strip
@jferris Owner
jferris added a note

Is there a test for this change?

@jkrall
jkrall added a note

Nope, actually that one snuck into this commit by accident. Sorry about that.

I'll fix it if you want... but honestly, this commit is really straightforward. If you don't want to pull this b/c of the .to_s ... that's fine, but you should really consider just adding the email field check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
unless result == 'ok'
raise WebkitError, read_response
View
6 spec/driver_spec.rb
@@ -415,6 +415,7 @@
<form action="/" method="GET">
<input class="watch" type="text"/>
<input class="watch" type="password"/>
+ <input class="watch" type="email"/>
<textarea class="watch"></textarea>
<input class="watch" type="checkbox"/>
<input class="watch" type="radio"/>
@@ -471,6 +472,11 @@
subject.find("//li").map(&:text).should == keyevents
end
+ it "triggers email input events" do
+ subject.find("//input[@type='email']").first.set(newtext)
+ subject.find("//li").map(&:text).should == keyevents
+ end
+
it "triggers radio input events" do
subject.find("//input[@type='radio']").first.set(true)
subject.find("//li").map(&:text).should == %w(click change)
View
2  src/capybara.js
@@ -91,7 +91,7 @@ Capybara = {
set: function(index, value) {
var node = this.nodes[index];
var type = (node.type || node.tagName).toLowerCase();
- if (type == "text" || type == "textarea" || type == "password") {
+ if (type == "text" || type == "textarea" || type == "password" || type == "email") {
this.trigger(index, "focus");
node.value = "";
for(var strindex = 0; strindex < value.length; strindex++) {
Something went wrong with that request. Please try again.