* 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)
| 584 | * @override |
| 585 | */ |
| 586 | handleFile(driver, file) { |
| 587 | return io.stat(file).then( |
| 588 | function (stats) { |
| 589 | if (stats.isDirectory()) { |
| 590 | return file // Not a valid file, return original input. |
| 591 | } |
| 592 | |
| 593 | let zip = new Zip() |
| 594 | return zip |
| 595 | .addFile(file) |
| 596 | .then(() => zip.toBuffer()) |
| 597 | .then((buf) => buf.toString('base64')) |
| 598 | .then((encodedZip) => { |
| 599 | let command = new cmd.Command(cmd.Name.UPLOAD_FILE).setParameter('file', encodedZip) |
| 600 | return driver.execute(command) |
| 601 | }) |
| 602 | }, |
| 603 | function (err) { |
| 604 | if (err.code === 'ENOENT') { |
| 605 | return file // Not a file; return original input. |
| 606 | } |
| 607 | throw err |
| 608 | }, |
| 609 | ) |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | // PUBLIC API |
nothing calls this directly
no test coverage detected