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
416751ab
...
416751abb2e9be9477f50c172bb138e6a78735f1
authored
2013-02-07 12:19:10 -0800
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #375 from lukeasrodgers/bugfix_getFormValues
Bugfix get form values
2 parents
6541ac75
70f2248e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
modules/clientutils.js
tests/suites/casper/formfill.js
modules/clientutils.js
View file @
416751a
...
...
@@ -478,7 +478,7 @@
if
(
type
===
'radio'
)
{
var
value
;
[].
forEach
.
call
(
inputs
,
function
(
radio
)
{
value
=
radio
.
checked
?
radio
.
value
:
undefined
;
value
=
radio
.
checked
?
radio
.
value
:
value
;
});
return
value
;
}
else
if
(
type
===
'checkbox'
)
{
...
...
@@ -511,7 +511,7 @@
var
self
=
this
;
[].
forEach
.
call
(
form
.
elements
,
function
(
element
)
{
var
name
=
element
.
getAttribute
(
'name'
);
if
(
name
)
{
if
(
name
&&
!
values
[
name
]
)
{
values
[
name
]
=
self
.
getFieldValue
(
name
);
}
});
...
...
tests/suites/casper/formfill.js
View file @
416751a
...
...
@@ -92,7 +92,7 @@ casper.test.begin('field array', 1, function(test) {
});
});
casper
.
test
.
begin
(
'getFormValues() tests'
,
1
,
function
(
test
)
{
casper
.
test
.
begin
(
'getFormValues() tests'
,
2
,
function
(
test
)
{
casper
.
start
(
'tests/site/form.html'
,
function
()
{
this
.
fill
(
'form[action="result.html"]'
,
{
email
:
'chuck@norris.com'
,
...
...
@@ -118,6 +118,31 @@ casper.test.begin('getFormValues() tests', 1, function(test) {
"topic"
:
"bar"
},
'Casper.getFormValues() retrieves filled values'
);
});
casper
.
then
(
function
()
{
this
.
fill
(
'form[action="result.html"]'
,
{
email
:
'chuck@norris.com'
,
password
:
'chuck'
,
content
:
'Am watching thou'
,
check
:
true
,
choice
:
'yes'
,
topic
:
'bar'
,
file
:
phantom
.
libraryPath
+
'/README.md'
,
'checklist[]'
:
[
'1'
,
'3'
]
});
});
casper
.
then
(
function
()
{
test
.
assertEquals
(
this
.
getFormValues
(
'form'
),
{
"check"
:
true
,
"checklist[]"
:
[
"1"
,
"3"
],
"choice"
:
"yes"
,
"content"
:
"Am watching thou"
,
"email"
:
"chuck@norris.com"
,
"file"
:
"C:\\fakepath\\README.md"
,
"password"
:
"chuck"
,
"submit"
:
"submit"
,
"topic"
:
"bar"
},
'Casper.getFormValues() correctly retrieves values from radio inputs regardless of order'
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
...
...
Please
register
or
sign in
to post a comment