* Prepares a `file` for use with the remote browser. If the provided path * does not reference a normal file (i.e. it does not exist or is a * directory), then the promise returned by this method will be resolved with * the original file path. Otherwise, this method will upload the file to
(driver, file)
| 593 | * @override |
| 594 | */ |
| 595 | handleFile(driver, file) { |
| 596 | return io.stat(file).then( |
| 597 | function (stats) { |
| 598 | if (stats.isDirectory()) { |
| 599 | return file // Not a valid file, return original input. |
| 600 | } |
| 601 | |
| 602 | let zip = new Zip() |
| 603 | return zip |
| 604 | .addFile(file) |
| 605 | .then(() => zip.toBuffer()) |
| 606 | .then((buf) => buf.toString('base64')) |
| 607 | .then((encodedZip) => { |
| 608 | let command = new cmd.Command(cmd.Name.UPLOAD_FILE).setParameter('file', encodedZip) |
| 609 | return driver.execute(command) |
| 610 | }) |
| 611 | }, |
| 612 | function (err) { |
| 613 | if (err.code === 'ENOENT') { |
| 614 | return file // Not a file; return original input. |
| 615 | } |
| 616 | throw err |
| 617 | }, |
| 618 | ) |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | // PUBLIC API |
nothing calls this directly
no test coverage detected