How to handle Login page on every test cases in test suite

how we handle Login page in every test cases in same project? if we are running test on same webpage where having login screen, i do not want having login in every test case, if the test case no fail, it shall proceed test on the current web without close the browser.

1 Like

I think we have the freedom to open or close the browser whenever we want with ‘Open Browser’ and ‘Close Browser’ keyword. So, in case we just want to open the browser one time, running some test cases and finally close the browser, I think about following solution:

  1. Create a test case, calling “Login”, in which, we just have 2 actions: open browser and (maybe) navigate to url. Then perform the login.
  2. Create some test cases that take ‘Home Page’ as pre-condition
  3. Create another test case, calling “Logout and Close”, in which, we perform logout and close browser.
  4. Add all above test cases into a test suite with correct order.

Then we will have the browser opened just one time and close when it completed.

Hope that it help.

I don’t know if OP’s problem have been solved but I was facing similar issue for Login and Logout.

This is the only solution I have right now for handling login and logout. I had to iterate through a webpage after login to download multiple reports sequentially from website and wanted to avoid logging in and logging out for each iteration.

I created three test cases

- Login to website

- Downloading Report test case

- Logout from website

Then created a test suite and added ONLY the “Downloading Report test case” to the test suite. I also added a test data with all report name entries in it.

After this, I added a listener with “Before Test Suite” and “After Test Suite” listener and called my login and logout test case in it. Something like this

    def sampleBeforeTestSuite(TestSuiteContext testSuiteContext) {
        println testSuiteContext.getTestSuiteId()
        WebUI.callTestCase(findTestCase("Test Cases/Wells_Login_Test_Case"), [:]
    def sampleAfterTestSuite(TestSuiteContext testSuiteContext) {
        println testSuiteContext.getTestSuiteId()
        WebUI.callTestCase(findTestCase("Test Cases/Wells_SignOff_Test_Case"), [:])

This solved my problem of logging in everytime for each iteration. If you are still looking for a solution, you can try this.