How to use the taiko.client function in taiko

To help you get started, we’ve selected a few taiko examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github getgauge / taiko / examples / 02-file_download.js View on Github external
(async () => {
  var downloadPath = path.resolve(__dirname, 'data', 'downloaded');
  var sleep = ms => {
    return new Promise(resolve => {
      setTimeout(resolve, ms);
    });
  };
  try {
    await openBrowserAndStartScreencast(
      path.join('captures', 'file-download', 'file-download.gif'),
    );
    await client().send('Page.setDownloadBehavior', {
      behavior: 'allow',
      downloadPath: downloadPath,
    });
    await goto('http://localhost:3000/download');

    // ensure that file_upload.js is run before this, to allow the file to be available for download
    await click('foo.txt');
    sleep(1000);
    expect(path.join(downloadPath, 'foo.txt')).to.exist;
  } catch (e) {
    console.error(e);
    process.exitCode = 1;
  } finally {
    await closeBrowserAndStopScreencast();
    fs.unlinkSync(path.join(downloadPath, 'foo.txt'));
  }

taiko

Taiko is a Node.js library for automating Chromium based browsers

MIT
Latest version published 4 months ago

Package Health Score

77 / 100
Full package analysis