CAPABILITY GENERATOR

LambdaTest DocumentationAutomation Testing ● Using Environment Variables For Authentication Credentials

Using Environment Variables For Authentication Credentials


In order to provide you with a secure cross browser testing environment on-cloud, we recommend you to integrate LambdaTest Authentication Credentials in your test scripts. This would allow our cloud servers to establish a secure connection between your local system & our cloud-based Selenium Grid. This document will help you understand how to set up your LambdaTest authentication credentials as environment variables for your respective operating system. This set up would also help authenticate your colleague’s test cases when executed against an individual account.

Where To Find LambdaTest Authentication Credentials?


LambdaTest Authentication Credential consists 2 fields:

  1. LambdaTest Username
  2. LambdaTest Access Key

You can find these authentication credentials by either visiting the Automation Dashboard or your LambdaTest Profile.

Fetching Authentication Credential from the Automation Tab


Step 1: Visit the Automation tab from the left navigation menu.

Step 2: Click on the key icon from the right side of your screen and copy the Access Key and Username.

key icon for environment variables

Fetching Authentication Credential from your LambdaTest Profile


Step 1: Visit your LambdaTest Profile by clicking on the user icon on the top-right & going to Profile.

Click User Icon and go to Profile

Step 2: You will find your Username & Access Key.

LambdaTest Profile

Configuring Environment Variables on Mac OSX/Linux Systems


Step 1: Open your terminal mode, and provide the command vi ~/.bash_profile & hit Enter.

Step 2: To perform text-insertion into your profile, you would need to press the i button from your keyboard.

Step 3: Feed LambdaTest Authentication credentials using the below:

Step 4: Hit Esc once you have entered the above lines into your Profile.

Step 5: Long-press the Shift button & hit Z twice (z z) to save your file and quit vi.

Step 6: Enter source ~/.bash_profile into the terminal.

Configuring Environment Variables on Windows Operating Systems


Step 1: Right-click on the Computer icon to access your Computer Properties. You could also follow the path(Control Panel\All Control Panel Items\System) into your computer address bar.

Step 2: Go-to Advanced system settings & click on Environment Variables.

environment variables from Advanced System Settings.

Step 3: You will notice a dialog would prompt open for the Environment Variables. Now, click on New under the System variables.

Step 4: Enter LT_USERNAME as the Variable name & provide your LambdaTest Username as the Variable value.

Step 5: Hit Ok & repeat the steps for adding LambdaTest Access Key as another System Envrionment Variable.

Incorporating Environment Variable In Selenium Automation Scripts

Now that we have set up our LambdaTest Authentication Credentials as System Environment Variables, we need to incorporate them in our Selenium automation scripts for invoking your automation test suites on LambdaTest Selenium Grid. In this section, you will learn how to reference environment variables for different programming languages with respect to LambdaTest Selenium Grid.

Java


  • For JUNIT & TestNG:

Python


  • For PyTest & unittest:

NodeJS


  • For Mocha-Chai & Jasmine-Chai:
  • For Protractor-Jasmine:

Ruby


  • For RSpec:

C#


  • For NUnit:

PHP


  • For Behat: