Usability - Productivity - Business - The web - Singapore & Twins

Supercharge SFDX with Ui-licious

You drank the Coolaid and you are all in and really love your Scratch Orgs. Just a few things drive you crazy.

When the API doesn't expose a setting

Your application is querying the OutOfOffice objects. Unfortunately they only exist when the Chatter settings have enabled them. To my best knowledge there is no API or config setting to achieve that from the command line. So automated testing in a scratch org won't work.

Ui-licious to the rescue

Ui-licious is a UI testing service that uses JavaScript as its scripting language. This makes an easy read and edit. A script that can set the missing OOO setting is short and simple (if you agree iFrames are easy to handle). You can (almost) read it out aloud:

// URL Provided by data object from the command line
I.must.see("Chatter Settings");
// To ensure we work on the iFrame we get the id
let iframeId = UI.execute("return document.getElementsByTagName('iframe')[0].getAttribute('id')");
// The iFrame loads slowly
UI.context("#" + iframeId, () => {
 I.see("Chatter is a corporate network that lets your users work together, talk to each other, and share information, all in real time.");
    I.select("Users can set Out of Office messages");

The interesting piece in the above is DATA.result.url which is an JSON object that needs to be handed over to the Ui-licious. A small command script in tandem with SFDX does the trick. The beauty here: we directly can reuse the output of an sfdx command as input for the uilicious-cli.

sfdx force:org:open -r -p lightning/setup/CollaborationSettings/home --json > local.json
uilicious-cli  run "ProjectName" "ScriptName" --dataFile local.json -u uiliciousUser -p uiliciousPassword

It probably would be part of a larger CI script, but you get the idea! You might not store the output in a file, but use bash to capture it in memory and use --dataObject instead. Full details are in the documentation.

As usual YMMV

Posted by on 27 November 2018 | Comments (1) | categories: Lightning Salesforce


  1. posted by Martin on Monday 03 December 2018 AD:

    Thanks, that (and activating manager groups) is right what is missing for us to completely automatize the scratch org creation process and boost efficiency.