# Staying in the same browser

**URL:** <https://forum.katalon.com/t/staying-in-the-same-browser/11748>\
**Category:** Miscellaneous\
**Created:** [June 27, 2018, 2:41pm UTC](https://forum.katalon.com/t/staying-in-the-same-browser/11748 "2018-06-27T14:41:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerome\_P](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jerome\_P](https://forum.katalon.com/u/Jerome_P)\
**Post date:** [June 27, 2018, 2:41pm UTC](https://forum.katalon.com/t/staying-in-the-same-browser/11748/1 "2018-06-27T14:41:03Z")

</div>

Hello everybody,

I have a quick question about web test :

- I made 2 test cases :

1. The first one consist to basically do an open page and login
2. The second to simply create a new (basic) planning on it

- And a « Test suite » that do the login first and  
new planning in second.

Problem is that when I do the test suite, each time at the  
end of the first test case, it close the browser and the second test is not  
performed due to the fact it’s not logged anymore on the page.

I firstly tried to manually edit the first test case about  
login to delete the close browser at the end of the script, and delete the open  
browser in the second, so normally the test suite should act like it’s one test  
on its own, but it seems not.

So is there a solution to stay on the same browser that has  
been opened on the first test case ? (to do all the next test cases properly),  
because for now on each test cases I have to perform a new login before each  
new test which is really frustrating)

Any help will be greatly appreciated,

Many thanks in advance,

Best regards

---

<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:** [June 27, 2018, 3:01pm UTC](https://forum.katalon.com/t/staying-in-the-same-browser/11748/2 "2018-06-27T15:01:39Z")

</div>

I, personally, prefer to login at each Test Case. It’s better to test one thing as a complete user scenario and workflow from beginning to end.

But that’s just me B)

Perhaps these settings are what you need?

![](https://s3.amazonaws.com/katalon-forum/editor/86/qyhltpiiz5a0.png "Image: https://s3.amazonaws.com/katalon-forum/editor/86/qyhltpiiz5a0.png")

[image.png](https://s3.amazonaws.com/katalon-forum/editor/86/qyhltpiiz5a0.png)

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [June 27, 2018, 3:18pm UTC](https://forum.katalon.com/t/staying-in-the-same-browser/11748/3 "2018-06-27T15:18:21Z")

</div>

you can also call Login TC from 2nd one where you just navigate to some page you want.  
Then in Test Suite you will define only 2nd TC

---

<div class="post-metadata">

**Author:** ![Jerome\_P](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jerome\_P](https://forum.katalon.com/u/Jerome_P)\
**Post date:** [June 28, 2018, 9:12am UTC](https://forum.katalon.com/t/staying-in-the-same-browser/11748/4 "2018-06-28T09:12:45Z")

</div>

Thanks for your both answers, appreciated.

> Russ Thomas said:
> 
> I, personally, prefer to login at each Test Case. It’s better to test one thing as a complete user scenario and workflow from beginning to end.
> 
> But that’s just me B)
> 
> Perhaps these settings are what you need?
> 
> ![](https://s3.amazonaws.com/katalon-forum/editor/86/qyhltpiiz5a0.png)

Yup, I already tried those settings but same issue ☹  
Anyway you are right, why not including a login on each TC after all.

> Andrej Podhajský said:
> 
> you can also call Login TC from 2nd one where you just navigate to some page you want.  
> Then in Test Suite you will define only 2nd TC

Interesting, can you give me a little more details on this ? (not sure to understand)  
I tried to launch my login TC and then let alone in my TS the second TC (create a new planning) but problem looks to be the same, it always launch in a new browser instance instead of using the one we choose (the already opened from the login TC) ☹

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [June 28, 2018, 10:31am UTC](https://forum.katalon.com/t/staying-in-the-same-browser/11748/5 "2018-06-28T10:31:53Z")

</div>

TC1 - Login to page (w/o logout)  
TC2 - Business logic after login

TC1 - start script with OpenBrowser() and navigateTo(); do login stuff, dont close browser so no closeBrowser() on end of script

TC2 - start script with callTestCase() with TC1 as parameter what TC you want to call; then do not use openBrowser() again, use navigateTo() to get to page you want to use; if needed, call closeBrowser() on the end

In TestSuite - you need to call only TC2

---

<div class="post-metadata">

**Author:** ![Jerome\_P](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jerome\_P](https://forum.katalon.com/u/Jerome_P)\
**Post date:** [June 29, 2018, 7:30am UTC](https://forum.katalon.com/t/staying-in-the-same-browser/11748/6 "2018-06-29T07:30:00Z")

</div>

> [Andrej Podhajský](https://forum.katalon.com/profile/2584/Andrej%20Podhajsk%C3%BD) said:
> 
> TC1 - Login to page (w/o logout)  
> TC2 - Business logic after login
> 
> TC1 - start script with OpenBrowser() and navigateTo(); do login stuff, dont close browser so no closeBrowser() on end of script
> 
> TC2 - start script with callTestCase() with TC1 as parameter what TC you want to call; then do not use openBrowser() again, use navigateTo() to get to page you want to use; if needed, call closeBrowser() on the end
> 
> In TestSuite - you need to call only TC2

Thank you very much Andrej, it worked like a charm with what you said!  
Cheers’

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [June 29, 2018, 7:57am UTC](https://forum.katalon.com/t/staying-in-the-same-browser/11748/7 "2018-06-29T07:57:10Z")

</div>

Hello Jerome,  
there is one step beyond this solution. Now when you make login TC sub case, you can turn it into user keyword to transform page logic into business logic.  
1. create user keyword  
2. copy all steps for login to this keyword definition (you can add parameters like login, password)  
3. in all tests that needs login you will just call User keyword login: test steps then can look like:  
A. Open browser  
B. Call loginUserKeyword (that will navigate to login page)  
C. do all other staff you need  
D. Close page
