Richard Lilli
Katalon Apprentice
06/13/2018

Assert Stopping Script

Hello, I have an issue with an assertion stopping my script and not continuing execution to close the browser. I am checking that a user sees the homepage after entering correct credentials. In the scenario that the wrong credentials have been entered this stops after the assert, I get the right error, but the browser is never closed.

I know in other functions that you can add the FailureHandler as a parameter and tell it to continue. But assert isn't called in the same way. I was considering a try/catch/finally statement but feel that is bad practice. Any advice? Thanks in advance!

**CODE********************************************
//After user enters correct credentials, user should see the homepage
assert WebUI.getWindowTitle() == GlobalVariable.homePage_PageTitle

//If bad credentials then execution does not continue to close the browser window
WebUI.closeBrowser()
******************************************************
Upvote
Quote

Comments

  • Marek Melocik
    Katalon Ambassador
    06/13/2018
    edited June 13
    Hi Richard,

    what about simple condition?

    if(WebUI.getWindowTitle() != GlobalVariable.homePage_PageTitle) {
    KeywordUtil.markFailedAndStop("Invalid window title.")
    }
    Upvote
    Quote
  • Richard Lilli
    Katalon Apprentice
    06/13/2018
    Hi Richard,

    what about simple condition?

    if(WebUI.getWindowTitle() != GlobalVariable.homePage_PageTitle) {
    KeywordUtil.markFailedAndStop("Invalid window title.")
    }
    That worked beautifully, thank you Marek.
    Upvote
    Quote
Sign In or Register to comment.