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
55b648e8
...
55b648e883e27b4e72e9b3b54b1835c3f614f8de
authored
2013-02-24 23:58:01 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed file upload paths in tests
1 parent
189b18fc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
9 deletions
modules/casper.js
tests/suites/casper/formfill.js
tests/suites/tester/assert.js
modules/casper.js
View file @
55b648e
...
...
@@ -731,8 +731,11 @@ Casper.prototype.fill = function fill(selector, vals, submit) {
}
else
{
(
function
_each
(
self
)
{
fillResults
.
files
.
forEach
(
function
_forEach
(
file
)
{
if
(
!
file
||
!
file
.
path
)
{
return
;
}
if
(
!
fs
.
exists
(
file
.
path
))
{
throw
new
CasperError
(
'Cannot upload
u
nexistent file: '
+
file
.
path
);
throw
new
CasperError
(
'Cannot upload
no
nexistent file: '
+
file
.
path
);
}
var
fileFieldSelector
=
[
selector
,
'input[name="'
+
file
.
name
+
'"]'
].
join
(
' '
);
self
.
page
.
uploadFile
(
fileFieldSelector
,
file
.
path
);
...
...
tests/suites/casper/formfill.js
View file @
55b648e
/*global casper __utils__*/
/*jshint strict:false*/
var
fs
=
require
(
'fs'
);
casper
.
test
.
begin
(
'fill() tests'
,
15
,
function
(
test
)
{
casper
.
start
(
'tests/site/form.html'
,
function
()
{
this
.
fill
(
'form[action="result.html"]'
,
{
...
...
@@ -101,6 +103,8 @@ casper.test.begin('field array', 1, function(test) {
});
casper
.
test
.
begin
(
'getFormValues() tests'
,
2
,
function
(
test
)
{
var
fpath
=
fs
.
pathJoin
(
phantom
.
casperPath
,
'README.md'
);
casper
.
start
(
'tests/site/form.html'
,
function
()
{
this
.
fill
(
'form[action="result.html"]'
,
{
email
:
'chuck@norris.com'
,
...
...
@@ -109,7 +113,7 @@ casper.test.begin('getFormValues() tests', 2, function(test) {
check
:
true
,
choice
:
'no'
,
topic
:
'bar'
,
file
:
phantom
.
casperPath
+
'/README.md'
,
file
:
fpath
,
'checklist[]'
:
[
'1'
,
'3'
]
});
});
...
...
@@ -120,7 +124,7 @@ casper.test.begin('getFormValues() tests', 2, function(test) {
"choice"
:
"no"
,
"content"
:
"Am watching thou"
,
"email"
:
"chuck@norris.com"
,
"file"
:
"C:\\fakepath\\README.md"
,
"file"
:
fpath
,
"password"
:
"chuck"
,
"submit"
:
"submit"
,
"topic"
:
"bar"
...
...
@@ -134,7 +138,7 @@ casper.test.begin('getFormValues() tests', 2, function(test) {
check
:
true
,
choice
:
'yes'
,
topic
:
'bar'
,
file
:
phantom
.
casperPath
+
'/README.md'
,
file
:
fpath
,
'checklist[]'
:
[
'1'
,
'3'
]
});
});
...
...
@@ -145,7 +149,7 @@ casper.test.begin('getFormValues() tests', 2, function(test) {
"choice"
:
"yes"
,
"content"
:
"Am watching thou"
,
"email"
:
"chuck@norris.com"
,
"file"
:
"C:\\fakepath\\README.md"
,
"file"
:
fpath
,
"password"
:
"chuck"
,
"submit"
:
"submit"
,
"topic"
:
"bar"
...
...
tests/suites/tester/assert.js
View file @
55b648e
...
...
@@ -67,7 +67,7 @@ casper.test.begin('Common assertions tests', 43, function(test) {
});
});
casper
.
test
.
begin
(
'filled inputs'
,
7
,
function
(
test
)
{
casper
.
test
.
begin
(
'
Tester.assertField():
filled inputs'
,
7
,
function
(
test
)
{
casper
.
start
(
'tests/site/form.html'
,
function
()
{
this
.
fill
(
'form[action="result.html"]'
,
{
'email'
:
''
,
...
...
@@ -90,8 +90,8 @@ casper.test.begin('filled inputs', 7, function(test) {
});
});
casper
.
test
.
begin
(
'unfilled inputs'
,
7
,
function
(
test
)
{
var
fpath
=
phantom
.
libraryPath
+
'/README.md'
;
casper
.
test
.
begin
(
'
Tester.assertField():
unfilled inputs'
,
7
,
function
(
test
)
{
var
fpath
=
fs
.
pathJoin
(
phantom
.
casperPath
,
'README.md'
)
;
casper
.
start
(
'tests/site/form.html'
,
function
()
{
this
.
fill
(
'form[action="result.html"]'
,
{
'email'
:
'chuck@norris.com'
,
...
...
@@ -107,7 +107,7 @@ casper.test.begin('unfilled inputs', 7, function(test) {
test
.
assertField
(
'check'
,
true
,
'Tester.assertField() works as expected with checkboxes'
);
test
.
assertField
(
'choice'
,
'no'
,
'Tester.assertField() works as expected with radios'
);
test
.
assertField
(
'topic'
,
'bar'
,
'Tester.assertField() works as expected with selects'
);
test
.
assertField
(
'file'
,
'C:\\fakepath\\README.md'
,
'Tester.assertField() works as expected with file inputs'
);
test
.
assertField
(
'file'
,
fpath
,
'Tester.assertField() works as expected with file inputs'
);
test
.
assertField
(
'checklist[]'
,
[
'1'
,
'3'
],
'Tester.assertField() works as expected with check lists'
);
}).
run
(
function
()
{
test
.
done
();
...
...
Please
register
or
sign in
to post a comment