refs #525 Allow to upload multiple files at once #526
Conversation
} | ||
this.page.uploadFile(fileFieldSelector, file.path); | ||
|
||
if (utils.isObject(file.path) && file.path.length>1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use 4 spaces indentation, and add spaces around operand (>
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
This would be a nice addition. Any updates on it yet? |
I'm in holidays using a crappy edge connection, maybe @laurentj could have a look? Also, AFAICS tests are failing. |
</head> | ||
<body> | ||
<form action="result.html" enctype="multipart/form-data"> | ||
<input type="file" name="files[]" multiple="multiple"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation problem here
Poke. |
I was in holidays. |
No pb take your time:)
|
Simplify code (refactoring)
I fix indentation and simplify a bit code in modules/casper.js |
Casper.prototype.getFileFieldSelector = function getFileFieldSelector(selector, file) { | ||
"use strict"; | ||
if (file.type === "names") { | ||
return [selector, 'input[name="' + file.selector + '"]'].join(' '); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take care of the indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
throw new CasperError('Cannot upload nonexistent file: ' + file_path); | ||
}; | ||
fpaths.push(file_path); | ||
}, this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pass the map
function inline: paths.map(function(filePath)…
; also, use camel case var/method naming
The patch looks good, though some minor CS issues to be addressed. Also, please ensure to rebase on top of latest master. (Sorry for the latency, I've been quite busy with other fronts these last months) |
Simplify code (refactoring)
Simplify code.
I came across this when trying to upload multiple files to an HTML5 file type input element. Applying the changes in casper.prototype.fillForm and the new function casper.prototype.getFileFieldSelector makes the functionality work. I understand that there are some minor coding standard issue. I am not sure if @nikrou has any plans to submit and update especially since it's more than 2 years old. Could the issues be fixed and merged please? |
@albuquerque can you apply the update in a new pull request and submit it ? It's the best chance to get this feature accepted atm 👍 |
Will do @mickaelandrieu. I didn't touch the tests. Will update it and submit. |
Abandoned. Closing in favor of #1425 that is about to be merged. |
I wrote a simple test.
The code to be updated is in fillForm() method and can be surely improved.