Staying in the same browser

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

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?

image.png

1 Like

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

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?

Yup, I already tried those settings but same issue :frowning:
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) :frowning:

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

1 Like

Andrej Podhajský 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’

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

1 Like