Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

How to set a global Base URL for every test case of one test suite in Selenium IDE so that I can switch to the different environments easily?

1 Answer

0 votes
by (62.9k points)

If you have a lot of test cases in a single suite, it might be difficult to change the Base URL for each. Instead, create a separate case for each Base URL you need to switch between. For example, I have to store https://testing.site.com/asmyEnvironment saved as test case SetEnvTesting. I create another case for my production site, SetEnvProduction.

Then, insert the ${myEnvironment} at the beginning of each relative URL in your test cases. For example, open ${myEnvironment}/login.aspx. (This might be a pain if you've got a lot of tests already. I suggest just adding it from now on.) Then, simply put the set-environment test case at the beginning of your test suite. To switch your entire suite to another Base URL, simply put a different set-environment case at the start. Another nice thing is that you can switch environments in the middle of the suite by putting a different set-environment case in the middle.

Edit: Example of using a SetEnvironment test case.

The SetEnvironment case: enter image description here

An example of the following test case. enter image description here

Note:

  1. how the CurrentEnvironment variable is used. You can do this for every case in the suite. Additionally, you can make every separate test suite use this same SetEnvironment case, so they all switch together.

  2. that the Base Url becomes irrelevant. You're overriding it, essentially.

 I hope it helps!

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s online Selenium course!

Browse Categories

...