Commit e803e6dc e803e6dc44374cca2ffdaea7fb6bc57f4f2e0e7c by Dmitry Menshikov

sendKeys for input without text attribute

1 parent 4f4165b6
...@@ -1554,7 +1554,7 @@ Casper.prototype.sendKeys = function(selector, keys, options) { ...@@ -1554,7 +1554,7 @@ Casper.prototype.sendKeys = function(selector, keys, options) {
1554 "hidden", "month", "number", "password", "range", "search", 1554 "hidden", "month", "number", "password", "range", "search",
1555 "tel", "text", "time", "url", "week"], 1555 "tel", "text", "time", "url", "week"],
1556 isTextInput = false; 1556 isTextInput = false;
1557 if (tag === 'textarea' || (tag === 'input' && supported.indexOf(type) !== -1)) { 1557 if (tag === 'textarea' || (tag === 'input' && (typeof type === 'undefined' || supported.indexOf(type) !== -1))) {
1558 // clicking on the input element brings it focus 1558 // clicking on the input element brings it focus
1559 isTextInput = true; 1559 isTextInput = true;
1560 this.click(selector); 1560 this.click(selector);
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
23 <input type="checkbox" name="checklist[]" value="3"> 23 <input type="checkbox" name="checklist[]" value="3">
24 <input type="submit" name="submit" value="submit"> 24 <input type="submit" name="submit" value="submit">
25 </form> 25 </form>
26 <form id="no-type-test-form" action="#" enctype="multipart/form-data">
27 <input name="notype">
28 <form>
26 <script> 29 <script>
27 (function () { 30 (function () {
28 'use strict'; 31 'use strict';
......
...@@ -2,19 +2,25 @@ ...@@ -2,19 +2,25 @@
2 /*global CasperError, casper, console, phantom, require*/ 2 /*global CasperError, casper, console, phantom, require*/
3 var utils = require('utils'); 3 var utils = require('utils');
4 4
5 casper.test.begin('sendKeys() tests', 3, function(test) { 5 casper.test.begin('sendKeys() tests', 4, function(test) {
6 casper.start('tests/site/form.html', function() { 6 casper.start('tests/site/form.html', function() {
7 this.sendKeys('input[name="email"]', 'duke@nuk.em'); 7 this.sendKeys('input[name="email"]', 'duke@nuk.em');
8 this.sendKeys('input[name="language"]', 'fr', {keepFocus: true}); 8 this.sendKeys('input[name="language"]', 'fr', {keepFocus: true});
9 this.click('#autocomplete li:first-child'); 9 this.click('#autocomplete li:first-child');
10 this.sendKeys('textarea', "Damn, I’m looking good."); 10 this.sendKeys('textarea', "Damn, I’m looking good.");
11 var values = this.getFormValues('form'); 11 var values = this.getFormValues('form[action="result.html"]');
12 test.assertEquals(values.email, 'duke@nuk.em', 12 test.assertEquals(values.email, 'duke@nuk.em',
13 'Casper.sendKeys() sends keys to given input'); 13 'Casper.sendKeys() sends keys to given input');
14 test.assertEquals(values.language, 'french', 14 test.assertEquals(values.language, 'french',
15 'Casper.sendKeys() sends keys to given input and keeps focus afterweards'); 15 'Casper.sendKeys() sends keys to given input and keeps focus afterweards');
16 test.assertEquals(values.content, "Damn, I’m looking good.", 16 test.assertEquals(values.content, "Damn, I’m looking good.",
17 'Casper.sendKeys() sends keys to given textarea'); 17 'Casper.sendKeys() sends keys to given textarea');
18
19 this.sendKeys('input[name="notype"]', "I have no type.");
20 values = this.getFormValues('form#no-type-test-form');
21 test.assertEquals(values.notype, "I have no type.",
22 'Casper.sendKeys() sends keys to given input without type attribute');
23
18 }).run(function() { 24 }).run(function() {
19 test.done(); 25 test.done();
20 }); 26 });
......