File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
java/client/test/org/openqa/selenium Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 25
25
import static org .junit .Assert .assertThat ;
26
26
import static org .junit .Assume .assumeFalse ;
27
27
import static org .openqa .selenium .WaitingConditions .elementValueToEqual ;
28
- import static org .openqa .selenium .testing .Ignore .Driver .ALL ;
29
28
import static org .openqa .selenium .testing .Ignore .Driver .CHROME ;
30
29
import static org .openqa .selenium .testing .Ignore .Driver .HTMLUNIT ;
31
30
import static org .openqa .selenium .testing .Ignore .Driver .IE ;
@@ -781,6 +780,16 @@ public void canSafelyTypeOnElementThatIsRemovedFromTheDomOnKeyPress() {
781
780
assertThat (getValueText (log ), anyOf (equalTo (expected ), equalTo (expected + "\n keyup (body)" )));
782
781
}
783
782
783
+ @ Test
784
+ public void canClearNumberInputAfterTypingInvalidInput () {
785
+ driver .get (pages .formPage );
786
+ WebElement input = driver .findElement (By .id ("age" ));
787
+ input .sendKeys ("e" );
788
+ input .clear ();
789
+ input .sendKeys ("3" );
790
+ assertEquals ("3" , input .getAttribute ("value" ));
791
+ }
792
+
784
793
private static String getValueText (WebElement el ) {
785
794
// Standardize on \n and strip any trailing whitespace.
786
795
return el .getAttribute ("value" ).replace ("\r \n " , "\n " ).trim ();
Original file line number Diff line number Diff line change @@ -91,6 +91,12 @@ bot.action.clear = function(element) {
91
91
if ( element . value ) {
92
92
element . value = '' ;
93
93
bot . events . fire ( element , bot . events . EventType . CHANGE ) ;
94
+ } else if ( bot . dom . isElement ( element , goog . dom . TagName . INPUT ) &&
95
+ element . getAttribute ( 'type' ) . toLowerCase ( ) == "number" ) {
96
+ // number input fields that have invalid inputs
97
+ // report their value as empty string with no way to tell if there is a
98
+ // current value or not
99
+ element . value = '' ;
94
100
}
95
101
96
102
if ( bot . dom . isContentEditable ( element ) ) {
You can’t perform that action at this time.
0 commit comments