# Is it possible to use the same test for different sites?

**URL:** <https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857>\
**Category:** Miscellaneous\
**Created:** [March 22, 2018, 10:41am UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857 "2018-03-22T10:41:34Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anastasia\_Boyer](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Anastasia\_Boyer](https://forum.katalon.com/u/Anastasia_Boyer)\
**Post date:** [March 22, 2018, 10:41am UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/1 "2018-03-22T10:41:34Z")

</div>

We have a few web products in our company that have the same structure, only the design is different. The idea we have, is to use the same tests for different sites and change only the site URL when running them? Is it possible & how can it be built in Katalon?  
Thank you.

---

<div class="post-metadata">

**Author:** ![Vladislav\_Lepichin](https://avatars.discourse-cdn.com/v4/letter/v/3ab097/32.png) [@Vladislav\_Lepichin](https://forum.katalon.com/u/Vladislav_Lepichin)\
**Post date:** [March 22, 2018, 10:50am UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/2 "2018-03-22T10:50:07Z")

</div>

I think not, because the objects will not be the same.

---

<div class="post-metadata">

**Author:** ![Anastasia\_Boyer](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Anastasia\_Boyer](https://forum.katalon.com/u/Anastasia_Boyer)\
**Post date:** [March 22, 2018, 11:14am UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/3 "2018-03-22T11:14:44Z")

</div>

They all use the same classes

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [March 22, 2018, 12:13pm UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/4 "2018-03-22T12:13:01Z")

</div>

Hi Anastasia

Yes, it is. I have suites which target different sites. The suites contain the same TestObjects and TestCases built from them.

---

<div class="post-metadata">

**Author:** ![Rudra](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@Rudra](https://forum.katalon.com/u/Rudra)\
**Post date:** [March 22, 2018, 12:34pm UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/5 "2018-03-22T12:34:53Z")

</div>

Yes Can be done easily, Only constraint is need to have same object across different websites

---

<div class="post-metadata">

**Author:** ![FachrulCH](https://avatars.discourse-cdn.com/v4/letter/f/ce73a5/32.png) [@FachrulCH](https://forum.katalon.com/u/FachrulCH)\
**Post date:** [March 22, 2018, 12:35pm UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/6 "2018-03-22T12:35:00Z")

</div>

it can reuse, as long as the locator still valid (using same element id)

---

<div class="post-metadata">

**Author:** ![Anastasia\_Boyer](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Anastasia\_Boyer](https://forum.katalon.com/u/Anastasia_Boyer)\
**Post date:** [March 22, 2018, 1:03pm UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/7 "2018-03-22T13:03:15Z")

</div>

Thank you all, how this kind of test can be built? How can we change the site URL in each run?

---

<div class="post-metadata">

**Author:** ![FachrulCH](https://avatars.discourse-cdn.com/v4/letter/f/ce73a5/32.png) [@FachrulCH](https://forum.katalon.com/u/FachrulCH)\
**Post date:** [March 22, 2018, 1:22pm UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/8 "2018-03-22T13:22:40Z")

</div>

In my case, i’m putting the URL in globalvariable, and before run i replace the Globalvariable for UAT or Staging or even production.  
We can use terminal (bash) “sed -i” to replace string inside file, or we can have multiple GlobalVariables.glbl (like GlobalVariables.uat, GlobalVariables.staging) and rename before run 😃

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [March 22, 2018, 1:24pm UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/9 "2018-03-22T13:24:18Z")

</div>

I use one special TestCase in each suite that logs in and sets a GlobalVariable to the correct URL. Then all other TestCases in the suite refer to the current value of the GlobalVariable.

---

<div class="post-metadata">

**Author:** ![Dave\_Evers](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/dave_evers/32/435_2.png) [@Dave\_Evers](https://forum.katalon.com/u/Dave_Evers)\
**Post date:** [March 22, 2018, 10:41pm UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/10 "2018-03-22T22:41:54Z")

</div>

How do you do this from test case: “set a GlobalVariable to the correct URL.”

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [March 23, 2018, 2:47am UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/11 "2018-03-23T02:47:37Z")

</div>

Let’s say I have two test suites which contain mostly identical test cases… let’s say, 100 to keep it simple.

99 of the test cases login a test user to the “current url”. One test case logs in the test user to a specific url, drawn from a GlobalVariable set to a fixed url for that test suite. For example, for a server called “mars”…

GlobalVariable.MARS -\> “[https://path.to.mars/](https://path.to.mars/)”

For the mars test suite, a “setter” test case needs to run first, which logs a test user in to mars and sets the “current url” (TARGET\_URL) for the other 99 test cases:

```auto
  GlobalVariable.TARGET_URL = GlobalVariable.MARS

```

So the other 99 test cases only need to refer to GlobalVariable.TARGET\_URL and as long as the “setter” test case runs first in the suite, everything works.

For the second server, Jupiter, I have another GV preset like this:

GlobalVariable.JUPITER -\> “[https://path.to.jupiter/](https://path.to.jupiter/)”

The Jupiter suite uses another “setter” test case where TARGET\_URL is set accordingly:

```auto
  GlobalVariable.TARGET_URL = GlobalVariable.JUPITER

```

And the same 99 test cases above now work against a different server/url.

It’s funny how sometimes explaining something can make it sound more complicated than it actually is (or perhaps I don’t explain it so well? ;)) All I’m really doing is decoupling the body of the suite(s) and their test cases from the server(s) and URL(s).

Russ

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [March 26, 2018, 1:09pm UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/12 "2018-03-26T13:09:40Z")

</div>

If anyone likes the general idea I posted above and would like to take it to the next level, then check out Kazurayam’s excellent **katalon.properties** approach on Github:

> **[kazurayam/KatalonPropertiesDemo](https://github.com/kazurayam/KatalonPropertiesDemo)**
>
> katalon.properties file enhances usability of Katalon Studio - kazurayam/KatalonPropertiesDemo

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 27, 2018, 7:31am UTC](https://forum.katalon.com/t/is-it-possible-to-use-the-same-test-for-different-sites/9857/13 "2018-03-27T07:31:03Z")

</div>

Please have a look at this:

> **[katalon.properties file and JVM System Property katalon.user.home](http://forum.katalon.com/discussion/5780/katalon-properties-file-and-jvm-system-property-katalon-user-home#latest)**
>
> Problems to solve Let me assume, I have a single Web Application in multiple environments:

Hope this helps.
