Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
e803e6dc
...
e803e6dc44374cca2ffdaea7fb6bc57f4f2e0e7c
authored
2013-07-08 19:27:52 +0300
by
Dmitry Menshikov
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
sendKeys for input without text attribute
1 parent
4f4165b6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
3 deletions
modules/casper.js
tests/site/form.html
tests/suites/casper/keys.js
modules/casper.js
View file @
e803e6d
...
...
@@ -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
);
...
...
tests/site/form.html
View file @
e803e6d
...
...
@@ -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'
;
...
...
tests/suites/casper/keys.js
View file @
e803e6d
...
...
@@ -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
();
});
...
...
Please
register
or
sign in
to post a comment