How to use the taiko.goto 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'));
  }
})();
github getgauge / taiko / examples / 07-dynamic-loading.js View on Github external
(async () => {
  try {
    // example 1
    await openBrowserAndStartScreencast(
      path.join('captures', 'dynamic-pages', 'dynamic-pages.gif'),
    );
    await goto('http://localhost:3000/dynamic_loading');
    await click('Example 1:');
    await click('Start');
    // no waits, taiko implicitly listens and waits for the right state.
    expect(await text('Hello World').exists()).to.be.true;

    // example 2
    await goto('http://localhost:3000/dynamic_loading');
    await click('Example 2:');
    await click('Start');
    expect(await text('Hello World').exists()).to.be.true;
  } catch (e) {
    console.error(e);
    process.exitCode = 1;
  } finally {
    await closeBrowserAndStopScreencast();
  }
})();
github getgauge / taiko / examples / 03-work-with-frames.js View on Github external
(async () => {
  try {
    await openBrowserAndStartScreencast(
      path.join('captures', 'frames', 'frames.gif'),
    );
    await goto('http://localhost:3000/nested_frames');
    expect(
      await text('MIDDLE').exists(),
      'expected "MIDDLE" to exist on page',
    ).to.be.true;
    // taiko does not need to be told about frames, it automagically figures it out.

    //TODO: tinyMCE example
  } catch (e) {
    console.error(e);
    process.exitCode = 1;
  } finally {
    await closeBrowserAndStopScreencast();
  }
})();
github getgauge / taiko / examples / 08-contenteditable.js View on Github external
(async () => {
  try {
    await openBrowserAndStartScreencast(
      path.join('captures', 'contenteditable', 'contenteditable.gif'),
    );
    // a local file with simple `contenteditable`
    await goto('file:///' + cwd + '/data/contenteditable.html');
    var text = 'Taiko writes into a contenteditable field!';
    await write(text, into(textBox(below('Editable Demo'))));
    var content = await textBox(below('Editable Demo')).text();
    expect(content).to.have.string(text);

    // a rich text editor
    await goto('http://localhost:3000/tinymce');
    text = 'Taiko writes into a tinyMCE editor';
    await write(text, into(textBox(below('An iFrame'))));
    content = await into(textBox(below('An iFrame'))).text();
    expect(content).to.have.string(text);
  } catch (e) {
    console.error(e);
    process.exitCode = 1;
  } finally {
    await closeBrowserAndStopScreencast();
  }
})();
github getgauge / taiko / examples / 08-contenteditable.js View on Github external
(async () => {
  try {
    await openBrowserAndStartScreencast(
      path.join('captures', 'contenteditable', 'contenteditable.gif'),
    );
    // a local file with simple `contenteditable`
    await goto('file:///' + cwd + '/data/contenteditable.html');
    var text = 'Taiko writes into a contenteditable field!';
    await write(text, into(textBox(below('Editable Demo'))));
    var content = await textBox(below('Editable Demo')).text();
    expect(content).to.have.string(text);

    // a rich text editor
    await goto('http://localhost:3000/tinymce');
    text = 'Taiko writes into a tinyMCE editor';
    await write(text, into(textBox(below('An iFrame'))));
    content = await into(textBox(below('An iFrame'))).text();
    expect(content).to.have.string(text);
  } catch (e) {
    console.error(e);
    process.exitCode = 1;
  } finally {
    await closeBrowserAndStopScreencast();
github saikrishna321 / taiko-android / __tests__ / launch.spec.js View on Github external
test('Should open browser and send events', async () => {
  await goto('http://the-internet.herokuapp.com/');
  let version = await evaluate(
    () => navigator.appVersion.match(/.*Chrome\/([0-9.]+)/)[1]
  );
  expect(version.result).toBeTruthy();
});
github getgauge / taiko / examples / 06-basic-auth.js View on Github external
(async () => {
  try {
    await openBrowserAndStartScreencast(
      path.join('captures', 'basic-auth', 'basic-auth.gif'),
    );
    await goto('http://admin:admin@localhost:3000/basic_auth');
    expect(
      await text(
        'Congratulations! You must have the proper credentials.',
      ).exists(),
    ).to.be.true;
  } catch (e) {
    console.error(e);
    process.exitCode = 1;
  } finally {
    await closeBrowserAndStopScreencast();
  }
})();
github getgauge / taiko / examples / 04-windows-tabs.js View on Github external
(async () => {
  try {
    const url = 'http://localhost:3000/windows';
    await openBrowserAndStartScreencast(
      path.join('captures', 'windows', 'windows.gif'),
    );
    await goto(url);
    await click('click here');
    expect(await title()).to.eq('The Internet Express');
    await closeTab();
    expect(await currentURL()).to.eq(url);
    expect(await text('Opening a new Window').exists()).to.be.true;
  } catch (e) {
    console.error(e);
    process.exitCode = 1;
  } finally {
    await closeBrowserAndStopScreencast();
  }
})();
github getgauge / taiko / examples / 05-dropdown.js View on Github external
(async () => {
  try {
    await openBrowserAndStartScreencast(
      path.join('captures', 'dropdown', 'dropdown.gif'),
    );
    await goto('http://localhost:3000/dropdown');
    expect(await dropDown().exists()).to.be.true;
    await dropDown().select('Option 1');
    expect(await dropDown().value()).to.eq('1');
  } catch (e) {
    console.error(e);
    process.exitCode = 1;
  } finally {
    await closeBrowserAndStopScreencast();
  }
})();
github getgauge / taiko / examples / 01-file_upload.js View on Github external
(async () => {
  try {
    await openBrowserAndStartScreencast(
      path.join('captures', 'file-upload', 'file-upload.gif'),
    );
    await goto('http://localhost:3000/upload');
    await attach(
      path.join(__dirname, 'data', 'foo.txt'),
      fileField(above(button('Upload'))),
    );
    await click('Upload');
    var exists = await text('file uploaded!').exists();
    expect(exists).to.be.true;
  } catch (e) {
    console.error(e);
    process.exitCode = 1;
  } finally {
    await closeBrowserAndStopScreencast();
  }
})();

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