Commit 52fd75d5 52fd75d511e78ee5f8cec37c44455d76d3501053 by Nicolas Perriault

Merge pull request #524 from WoZ/send-keys-for-inputs-without-type-attr

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