Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Environment Health Check - Test Plutora SSO Login
The following scripts accepts a URL and SSO Credentials as parameters passed in from the UI and logs into the Plutora Application using SSO
The script executes a headless selenium script to perform the test.
The script accepts a URL and API Credentials as parameters passed in from the UI, generates a Oauth token and makes a simple API call
The paramaters entered into the UI need to be named as follows and are case sensitive:
- url = <The url for your instance of Plutora>
- email = <The email address for your user>
- password = <The password address for your user>
- failureEmail = <email addresses of selected email recipients if the test fails>
The outcome of the test will return a true or false result via Promise.Resolve();
- resolve(true) = your environment is ONLINE
- resolve(false) = your environment is OFFLINE
Any thrown errors during script execution or a call to Reject will be treated as a result of Unknown
- ie - reject(true) = the status of your environment is UNKNOWN
The script will trigger an email notification if the test fails
let run = function (args) {
//Destructure paramater values that were set from the UI
let {url, email, password, failureEmails} = args.arguments;
return new Promise(async function (resolve, reject) {
console.log('Beginning EnvironmentCheck test');
//Execute the test
let driver = chromeDriver.driver;
try {
var testResult = null;
var expectedResult = "Plutora";
await driver.manage().window().maximize();
await driver.get(url);
await driver
.wait(chromeDriver.until.elementLocated({name: 'username'}), 200000)
.catch(function (err) {
await driver.sleep(2000);
await driver.findElement({css: '[class="pull-left col-md-3 ng-scope"] .btn-primary'}).click();
await driver.sleep(2000);
await driver.findElement({id: 'Email'}).sendKeys(email);
await driver.sleep(500);
await driver.findElement({id: "next"}).click();
await driver.sleep(1000);
await driver.findElement({id: 'Passwd'}).sendKeys(password);
await driver.sleep(500);
await driver.findElement({id: "signIn"}).click();
await driver.sleep(5000);
await driver
.wait(chromeDriver.until.elementLocated({xpath: "//*[@title='NPM Admin']"}), 20000)
.catch(function (err) {
await driver.getTitle().then(function (title) {
if (title == expectedResult) {
console.log("Test Passed");
testResult = true;
} else {
console.log("Test Failed");
testResult = false;
//Optional clause to send emails if a test fails to pass.
if (testResult = false) {
await sendFailureEmail(failureEmails, "Test completed but the result was a fail.")
if (testResult != null) {
catch (error) {
//Optional clause to send emails if a test fails to complete.
await sendFailureEmail(failureEmails, `Test did not complete due to error: ${error}`);
console.log('Completed EnvironmentCheck test');
const sendFailureEmail = async function (emails, message = null) {
mailData = {
to: emails, // Required - Address data can be passed as a single string with commas separating addresses or an array of single address strings. ie: ['', '']
subject: 'Environment Health Check Failure - SSO_Login', //Required
body: `A failure occured during the execution of this script. <b> Bold Text </b> <i>Italicized text</i> \n\n + ${message}` //Required - This accepts HTML or standard text input.
//signature: '\n\n\nCustom email signature.' //Optional. If excluded a default Plutora signature will be appended.
await mailer.send(mailData);
module.exports = {
run: run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.