Task Development

Learn how to code DEX8 Tasks

Package File

The file "package.json" contains very useful and powerful Javascript libraries such as:

  1. Puppeteer
  2. Cheerio
  3. Bluebird promises
  4. RxJS
  5. Moment
  6. Mongoose
  7. Lodash
  8. fs-extra
The file shouldn't be edited so if you add an additional package it will not work in the DEX8 Robot environment.
Please leave it as is.

We are assuming here that you want to use them while developing DEX8 Task so execute command:
$npm run inst-chromium or $ npm install.
It will install all the packages and you can use them in the task.

If you want to install Puppeteer faster without downloading the Chromium browser execute:
$ npm run inst or $ export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=false && npm install

dex8 init npm install

In this case you need to use a Chrome browser which should be installed on the Operating System and the executablePath should be defined.
// define chrome executable path
const osPlatform = os.platform(); // possible values are: 'darwin', 'freebsd', 'linux', 'sunos' or 'win32'
console.log('\nDEX8 Task is running on platform: ', osPlatform);
let executablePath;
if (/^win/i.test(osPlatform)) { // windows
  executablePath = '';
} else if (/^linux/i.test(osPlatform)) { // linux
  executablePath = '/usr/bin/google-chrome';

module.exports = {
  viewport: {
    width: 1300,
    height: 1100

  puppeteer: {
    executablePath: executablePath,
    headless: false,
    devtools: false,  // Open Chrome devtools at the beginning of the test
    dumpio: false,
    slowMo: 25,  // Wait 250 ms each step of execution, for example chars typing
    args: ['--ash-host-window-bounds=1300x1100', '--window-size=1300,1100', '--window-position=700,20']

const config = require('config.js');

module.exports = async function (x, libs) {
  const browser = await libs.puppeteer.launch(config.puppeteer);
  const page = await browser.newPage();
  await page.bringToFront();
  await page.setViewport({width: config.viewport.width, height: config.viewport.height});

  x.page = page;
  return x;