Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Don't clear readonly text fields when set

  • Loading branch information...
commit 136e0e2bb7aee35db746edba92ec551af5942c3f 1 parent a5c51b2
Matthew Horan authored March 20, 2013
7  spec/driver_spec.rb
@@ -773,6 +773,7 @@ def visit(url, driver=driver)
773 773
             <input type="text" name="foo" value="bar"/>
774 774
             <input type="text" name="maxlength_foo" value="bar" maxlength="10"/>
775 775
             <input type="text" id="disabled_input" disabled="disabled"/>
  776
+            <input type="text" id="readonly_input" readonly="readonly" value="readonly"/>
776 777
             <input type="checkbox" name="checkedbox" value="1" checked="checked"/>
777 778
             <input type="checkbox" name="uncheckedbox" value="2"/>
778 779
             <select name="animal">
@@ -981,6 +982,12 @@ def visit(url, driver=driver)
981 982
     it "knows a not disabled input is not disabled" do
982 983
       enabled_input['disabled'].should_not be_true
983 984
     end
  985
+
  986
+    it "does not modify a readonly input" do
  987
+      readonly_input = driver.find_css("#readonly_input").first
  988
+      readonly_input.set('enabled')
  989
+      readonly_input.value.should == 'readonly'
  990
+    end
984 991
   end
985 992
 
986 993
   context "dom events" do
2  spec/selenium_compatibility_spec.rb
@@ -9,6 +9,7 @@
9 9
         <form onsubmit="return false">
10 10
           <label for="one">One</label><input type="text" name="one" id="one" />
11 11
           <label for="two">Two</label><input type="text" name="two" id="two" />
  12
+          <label for="three">Three</label><input type="text" name="three" id="three" readonly="readonly" />
12 13
           <input type="submit" value="Submit" id="submit" />
13 14
         </form>
14 15
         <script type="text/javascript">
@@ -33,6 +34,7 @@
33 34
       fill_in "One", :with => "some value"
34 35
       fill_in "One", :with => "a new value"
35 36
       fill_in "Two", :with => "other value"
  37
+      fill_in "Three", :with => "readonly value"
36 38
       click_button "Submit"
37 39
     end
38 40
   end
4  src/capybara.js
@@ -242,7 +242,9 @@ Capybara = {
242 242
         length = value.length;
243 243
       }
244 244
 
245  
-      node.value = "";
  245
+      if (!node.readOnly)
  246
+        node.value = "";
  247
+
246 248
       for (strindex = 0; strindex < length; strindex++) {
247 249
         CapybaraInvocation.keypress(value[strindex]);
248 250
       }

0 notes on commit 136e0e2

Please sign in to comment.
Something went wrong with that request. Please try again.