I can't seem to be able to make fileUpload work, I am using the script below but from the screenshot it is obvious that the file is not even selected in the form: Screenshot
casper.thenOpen('https://encodable.com/uploaddemo/', function () {
this.waitForSelector(x('//input[@type="file"]'), function () {
casper.page.uploadFile(x('//input[@type="file"]'), '/Users/stratos/Desktop/IMG_1344.png');
});
});
casper.then(function () {
this.wait(5000, function () {
this.capture('test/integration/screenshots/uploadTest.png');
});
});
The test runs fine with no errors so I have no indication what is going on :(
I am using PhantomJS 2.1.1 and CasperJS 1.1.0-beta5
If the test presses the Upload button the page validation will trigger because of no file selected.
page.uploadFile()
is a PhantomJS function and doesn't support CasperJS' use of XPath expressions. It only accepts CSS selectors as a simple string:
casper.page.uploadFile('input[type="file"]', '/Users/stratos/Desktop/IMG_1344.png');