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

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.

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

They all use the same classes

Hi Anastasia

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

1 Like

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

1 Like

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

1 Like

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

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 :smiley:

1 Like

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.

2 Likes

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

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/”

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:

  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/”

The Jupiter suite uses another “setter” test case where TARGET_URL is set accordingly:

  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

1 Like

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:

Please have a look at this:

Hope this helps.