How to avoid reopen browser in a Test Suite Collection for each Test Suite

I have this situation:

  • Test Case: “Login”: Open Browser ()=> Login and so on.
  • Test Case: “Something after login”: click here and there.

and then I have many of these:

  • Test Suite: “Something beautiful”:
    — Test case “Login”;
    — Test case “Something after login”;
    — Test case “Another one test case and so on…”

and then I have also:

  • Test Suite Collection: “All my test suite!”
    — Test suite: “Something beautiful”
    — Test suite: “Another one test suite and so on…”

What I need is that in my Test Suite Collection I can avoid every time the “Login” step (which is in every Test Suite).

Maybe also with an “if (GlobalVariable.skip_login)”.

Today also if I do one Test Suite with just “Open Browser” action the browser close itself after that step and reopen itself for the next step in Test Suite Collection.

I’m sorry Hanh Tran, but this is not a right answer for my problem.

It seems to me you don’t understand what I need to do.

The GlobalVariable in a Test Collection is reset at every Test Suite start and than the Login step is repeated. After that there is another problem: every test suite close the browser also without WebUI.closeBrowser().

It’s a mess.

So things are getting complicated. What you are trying to do will break the usual flow of test suite if you execute it separately. I suggest that each Test Suites should be independent of each other , do not try to mess it.

I can suggest you the following workaround by having ‘gl_isLogin’ variable (default is true)

if (already logged in)

{

GlobalVariable.gl_isLogin = true

}

else

{

//Not logged in yet, insert login steps below

WebUI.setText(userName)

WebUI.setText(password)

.....

}

End of ‘Login’ Test Case before you trying to close browser

if (GlobalVariable.gl_isLogin == true)

{

//Do nothing

}

else

{

WebUI.closeBrowser()

}

Yes, but the browser is closed after each Test Suite in a collection!

Do you know any indications from your application that you’ve logged in successfully like successful login message? If so, you can add a flag in ‘Login’ test case to avoid re-executing:

if (condition to check for successful login)

{

//Do nothing here

}

else

{

//Not logged in yet, insert login steps below

WebUI.setText(userName)

WebUI.setText(password)

}