hi guys i am automating a note pad with a few test cases,
i noticed that everytime the test cases executed, a new notepad opens which eventually i have about 10 notepads opened.
so i would like to put a condition statement to check if the window application is opened, skip the start application command(startapplication.notedpad) and proceed the next line command?
Any experts help would appericate.
Thanks!!
Hi @devilgim88,
If you just feel uncomfortable with a lot of notepads opening. Why didn’t you just close it at the end of each test case /=)
I can’t, i have to run lots of test cases, i would really prefer if there is a check condition, any advise? Thanks!
Yeah, there is a piece of advice. You could use this strategy. Open it once, then do all the tests, and then close it.
You could achieve it by creating a global variable with a name like "isApplicationOpened"
with the initial value set to false.
And then in the @BeforeTestSuite listener, call to open your app and set the global variable "isApplicationOpened"
to true.
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
class TestSuiteListeners {
@BeforeTestSuite
def BeforeTestSuite(TestSuiteContext testSuiteContext) {
Windows.startApplication(GlobalVariable.application)
GlobalVariable.isApplicationOpened = true
}
}
Then in your test case
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
if (GlobalVariable.isApplicationOpened == false) {
Windows.startApplication(GlobalVariable.application)
}
// Do some stuff... click, verify...
if (GlobalVariable.isApplicationOpened == false) {
Windows.closeApplication()
}
~ I hope the above is useful to you /=)