Skip to content

Instantly share code, notes, and snippets.

@belajargitbinar
Last active December 13, 2023 12:46
Show Gist options
  • Save belajargitbinar/395621ad3bc0f2567ea10f857e07b2ed to your computer and use it in GitHub Desktop.
Save belajargitbinar/395621ad3bc0f2567ea10f857e07b2ed to your computer and use it in GitHub Desktop.
Test Hook Katalon
import com.kms.katalon.core.util.KeywordUtil
class Hook {
def openBrowser() {
WebUI.openBrowser('');
WebUI.maximizeWindow();
WebUI.navigateToUrl('https://www.saucedemo.com/');
}
def closeBrowser() {
WebUI.closeBrowser();
}
@BeforeTestCase
def beforeTestCase(TestCaseContext testCaseContext) {
KeywordUtil.logInfo('Test Case: ' + testCaseContext.getTestCaseId())
this.openBrowser()
}
@AfterTestCase
def afterTestCase(TestCaseContext testCaseContext) {
KeywordUtil.logInfo('Test Case: ' + testCaseContext.getTestCaseId())
this.closeBrowser()
}
@BeforeTestSuite
def beforeTestSuite(TestSuiteContext testSuiteContext) {
KeywordUtil.logInfo('Test Suite: ' + testSuiteContext.getTestSuiteId())
this.openBrowser()
}
@AfterTestSuite
def afterTestSuite(TestSuiteContext testSuiteContext) {
KeywordUtil.logInfo('Test Suite: ' + testSuiteContext.getTestSuiteId())
this.closeBrowser()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment