phantasma icon indicating copy to clipboard operation
phantasma copied to clipboard

There is no .upload() method like Nightmare has

Open Mako-L opened this issue 9 years ago • 7 comments

Mako-L avatar May 12 '15 00:05 Mako-L

Will make some user cases and tests when I have time for my commit.

Mako-L avatar May 16 '15 16:05 Mako-L

No need to close the issue it's entirely valid. Did you get anywhere on your PR?

petecoop avatar May 16 '15 22:05 petecoop

This is my version:

Phantasma.prototype.upload = function (selector, path) {
    var self = this;

    return new this.promise(function (resolve, reject) {
        self.page.uploadFile(selector, path);
        resolve();
    })
}

But It doesn't seem to work. Any chance you guys make a better version?

Mako-L avatar Sep 08 '15 11:09 Mako-L

Version 2 (still doesn't work)

Phantasma.prototype.upload = function (selector, path) {
    var self = this;

    return new this.promise(function (resolve, reject) {
        if (fs.existsSync(path)) {
            self.page.uploadFile(selector, path);
            console.log(path);
            resolve();
        } else {
            console.log("Didn't upload")
        }

    });
}

Mako-L avatar Sep 08 '15 12:09 Mako-L

Apparently it's phantomjs 2.0 fault. The fix is here : https://github.com/skakri/phantomjs/releases/tag/2.0.1-regression-12506 . Updating phantomjs to 2.0.1 will fix the bug and make the upload method work. So, my questions is: Do we implement the method and update the framework or will just w8 until 2.1 comes out?

Mako-L avatar Sep 08 '15 13:09 Mako-L

Sounds fine to put in but to just add a note in the documentation that it won't work if not using 2.0.1

petecoop avatar Sep 08 '15 18:09 petecoop

Was this fixed in the 2.1 phantomjs version? Can we integrate the .upload() function now?

Mako-L avatar May 31 '18 14:05 Mako-L