javascriptnode.jsjasmineprotractorsaucelabs

How to send different data to each script running in parallel using NodeJS, Protractor, and Saucelabs?


I have multiple automation scripts setup with NodeJS, Protractor, Jasmine Framework and SauceLabs.

Each script is in separate .JS files and it reads data from .JSON files. I have defined login credentials and all other necessary data within the JSON files.

multiCapabilities: [{
    browserName: 'chrome',
    version: 'latest',
    platform: 'Windows 8',
    name: "tests",
    splitTestsBetweenCapabilities: true,
    acceptInsecureCerts: true,
    cssSelectorsEnabled: true,
    shardTestFiles: true,
    maxInstances: 5,
}],
maxSessions: 5,

Using this config, I am able to trigger 5 instances of Chrome browser and run 5 different scripts each fetching data on their own.

The problem is I need to use a rotating list of 20 login credentials for each script. I am not sure if there are any packages that do this already.

How should I approach this, so that each script can use one unique username and password? Each script should be able to pick a random credential and other scripts shouldn't able to use that until that script completes its' run.


Solution

  • You can use a separate process to update the data on the .json files and then trigger the scripts as you would normally.

    There are npm packages like json-update available or you can build your own script to run before your script.