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.
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:
- Create a test case, calling âLoginâ, in which, we just have 2 actions: open browser and (maybe) navigate to url. Then perform the login.
- Create some test cases that take âHome Pageâ as pre-condition
- Create another test case, calling âLogout and Closeâ, in which, we perform logout and close browser.
- 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
@BeforeTestSuite
def sampleBeforeTestSuite(TestSuiteContext testSuiteContext) {
println testSuiteContext.getTestSuiteId()
WebUI.callTestCase(findTestCase("Test Cases/Wells_Login_Test_Case"), [:]
}
@AfterTestSuite
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.