Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a global Base URL for every test case of one test suite in Selenium IDE?

Tags:

selenium

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

like image 528
zs2020 Avatar asked Mar 18 '11 16:03

zs2020


People also ask

What is base URL in Selenium IDE?

The base URL should be the index of your site. NOT the directory under test. This will open http://google.com/search as the beginning Url. From then, you should continue testing.

Which browser does Selenium IDE supports to create and execute test cases?

Selenium IDE has add-ons for Firefox and Chrome browsers. Selenium IDE comes with a rich set of commands that are powered by Selenese and it allows you to record and test different interactions of a web application with the browser.

Which of the following command is used to open a webpage using URL in Selenium IDE?

Open (URL) - Selenium IDE command Meet Open - the most used command in the selenium IDE software testing tool. The "Open" command opens the URL in the current selected browser tab. The open command takes a full URL as input (recommended) or a path relative to the baseurl (outdated).


1 Answers

If you have a lot of test cases in a single suite, it's a pain 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 store https://testing.site.com/ as myEnvironment 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 a following test case. enter image description here

Notice

  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 that's helpful!

like image 93
arwenvh Avatar answered Sep 19 '22 00:09

arwenvh