How do environmental variables work in Alchemy, and how can I use them?

Posted 2 months ago by Sanjay

Post a topic
Answered
S
Sanjay

I want to know, what are the environmental variables an dhow can I use them in alchemy?

0 Votes

P

PrasadLangoju posted about 2 months ago Best Answer

In Alchemy, environment variables are used to store key-value pairs that can be accessed within tests. These variables allow you to configure aspects like browser settings, test environment details (such as URLs and credentials), or external API keys without hardcoding them into the test code. This practice improves test maintenance, scalability, and security, especially when moving tests across different environments.

It is common to have the same application deployed across different environments such as production, development, staging, and testing. However, the URLs for each environment are typically different. This allows the same application to be tested, developed, and validated in isolated environments without affecting production users.

Ex:-
The following example demonstrates how different URLs are used for test execution across various environments:

  1. Create a new suite.

  2. Add a test and record actions using any one of the URLs associated with your application.

  3. Navigate to the "Configurations" section, where you'll find the "Default," "Staging," and "Production" environments available.

  4. To add additional environments, click the "Add environment" button, provide a valid name, and confirm.

  5. By default, a variable called "Url" will be present. To add another URL, click the "Add variable" button.

  6. Enter the appropriate variable values in the corresponding fields and save.

  7. Select the desired environment from the "Current Configuration" dropdown menu.
  8. Goto the Test section, open the "Data Toolbox" and click on "Environmental variables" to see them.

  9. Drag and drop the "Url" variable into the "Navigate" step of the test.

  10. Execute the test.

  11. You’ll observe that the test runs according to the selected environment.

  12. Return to the "Configurations" section, change the environment, and save.

  13. Go back to the "Test" section and execute the same test again.

  14. You will notice that the same test is now executed in a different environment.

0 Votes


1 Comments

P

PrasadLangoju posted about 2 months ago Answer

In Alchemy, environment variables are used to store key-value pairs that can be accessed within tests. These variables allow you to configure aspects like browser settings, test environment details (such as URLs and credentials), or external API keys without hardcoding them into the test code. This practice improves test maintenance, scalability, and security, especially when moving tests across different environments.

It is common to have the same application deployed across different environments such as production, development, staging, and testing. However, the URLs for each environment are typically different. This allows the same application to be tested, developed, and validated in isolated environments without affecting production users.

Ex:-
The following example demonstrates how different URLs are used for test execution across various environments:

  1. Create a new suite.

  2. Add a test and record actions using any one of the URLs associated with your application.

  3. Navigate to the "Configurations" section, where you'll find the "Default," "Staging," and "Production" environments available.

  4. To add additional environments, click the "Add environment" button, provide a valid name, and confirm.

  5. By default, a variable called "Url" will be present. To add another URL, click the "Add variable" button.

  6. Enter the appropriate variable values in the corresponding fields and save.

  7. Select the desired environment from the "Current Configuration" dropdown menu.
  8. Goto the Test section, open the "Data Toolbox" and click on "Environmental variables" to see them.

  9. Drag and drop the "Url" variable into the "Navigate" step of the test.

  10. Execute the test.

  11. You’ll observe that the test runs according to the selected environment.

  12. Return to the "Configurations" section, change the environment, and save.

  13. Go back to the "Test" section and execute the same test again.

  14. You will notice that the same test is now executed in a different environment.

0 Votes

Login or Sign up to post a comment

© Orasi Software, Inc. | All Rights Reserved.