Skip to content

Commit

Permalink
[nodejs] Fixing file download test to actually download a file instea…
Browse files Browse the repository at this point in the history
…d of opening it in the browser
  • Loading branch information
barancev committed Jan 31, 2019
1 parent 9b3fa5a commit 5281fb7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions javascript/node/selenium-webdriver/test/chrome/devtools_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ test.suite(function(env) {
const dir = await io.tmpDir();
await driver.setDownloadPath(dir);

const url = fileServer.whereIs('/data/chrome/download.html');
const url = fileServer.whereIs('/data/firefox/webextension.xpi');
await driver.get(`data:text/html,<!DOCTYPE html>
<div><a download="" href="${url}">Go!</a></div>`);

await driver.findElement({css: 'a'}).click();

const downloadPath = path.join(dir, 'download.html');
await driver.wait(() => io.exists(downloadPath), 1000);
const downloadPath = path.join(dir, 'webextension.xpi');
await driver.wait(() => io.exists(downloadPath), 5000);

const goldenPath =
path.join(__dirname, '../../lib/test/data/chrome/download.html');
path.join(__dirname, '../../lib/test/data/firefox/webextension.xpi');
assert.equal(
fs.readFileSync(downloadPath, 'utf8'),
fs.readFileSync(goldenPath, 'utf8'));
fs.readFileSync(downloadPath, 'binary'),
fs.readFileSync(goldenPath, 'binary'));
});

it('throws if path is not a directory', async function() {
Expand Down

0 comments on commit 5281fb7

Please sign in to comment.