Intro guide; Node.js, Taiko, and Robin

Using Taiko with Robin

Taiko is a Node.js library for browser automation. It has a REPL that can generate basic Javascript code for you.

Why might you want to use it with Robin?

  • It’s really fast.
  • You need far fewer “wait” statements.
  • It will generate lots of code for you :grinning:

Why might you not want to use it with Robin?

  • The client machine will need Node.js installed, with all the headaches that involves.

Take a look at the REPL screenshot below.


Notice the line > .code mytest.js

That generated the basic JS code shown below:

Since this is RPA, we want to grab some information from the webpage, not just test it. Taiko can do that, but it’s not that easy to do from the REPL. We’ll just add the ‘evaluate’ functionality in manually, adding ‘evaluate’ to our ‘const’ too, also adding a parameter to make sure the browser doesn’t run headless, which sometimes doesn’t work well outside the REPL. Here’s what the code looks like after we add the “non-headless” code and an ‘evaluate’ function:

Now let’s call it from Robin, with our test file renamed to ‘robin3.js’:

Robin code:

System.GetEnvironmentVariable Name: 'USERNAME' Value=> UserName

System.RunDOSCommand \
    DOSCommandOrApplication: 'node robin3.js' \
    WorkingDirectory:'C:\Users\\'+UserName+'\Documents\Robin\9.2\node\february 2020' \
    StandardOutput=> StandardOutput \
    StandardError=> StandardError \
    ExitCode=> ExitCode

Console.Write \
    Message: StandardOutput


const { openBrowser, goto, write, click, closeBrowser, evaluate } = require('taiko');
(async () => {
    try {
        await openBrowser({headless:false});
        await goto("");
        await write("");
        await click("Google Search");
        await click("The RPA Language");
        let robin = await evaluate(() => {
        // Callback function have access to all DOM APIs available in the developer console.
        return document.body.innerText;
        } );
    } catch (error) {
    } finally {
        await closeBrowser();

Here’s an animated GIF (the highlighting is off-kilter due to my 125% scaling on Win7):