i am running a test case with a loop (570 iteration) inside, but the browser closed before finishing the loop and the rest of the code (it keeps executing , i can see it on the log viewer) .
How can i keep the browser open , so i can see the execution ?
Hello there!
Would you mind sharing the code so I can take a closer look?
Here are a few ideas to consider:
Are you using any Close Browser or similiar keyword inside the loop?
Is there any custom keyword being used in the loop?
Are you executing a Test Case or a Test Suite? As far as I remember, some Test Suite execution configurations might force the browser to close between test executions.
Not to be a noob, but what are you expecting from your loop. It will always go through all 577 items regardless where it finds your value and then (only temporarily, see below) retain the last time that “table[0]” was the same as your (spreadsheet) value. Is this what you want?
Also, the value of “K” will always be unknown outside of the “for loop” after it has finished because you instantiated/initialized it within the loop (so the scope of the variable will only be the loop).
Maybe
String K = ''
for (i=1;i<577;i++) {
if (table[0].equals(Data.getValue('ID',i))) {
K = Data.getValue('number',i)
break;
}
}
WebUI.comment("value of K is: ${K}")
What I think could be happening is that you have an incorrect statement that is causing your browser to crash, like maybe going outside the bounds of your “Data” array. Or, maybe you are trying to use the value of K outside of the loop and you have your project’s default FailureHandling set at STOP_ON_FAILURE.
Hmmm, okay. I guess that piece of code is part of a bigger test case, right? Do you have the Open Browser keyword at the beginning? Which browser are you using?
Also, could you share a log file? That would be really helpful.
I would also suggest debugging this using the debug option in Katalon or with some rudimentary debugging actions, like commenting out the loop and running only one straight iteration of your code to see if the browser remains open.
I suppose your Test Case terminiated (normally or abnormally, I don’t know; you described nothing), and the browser closed as soon as the Test Case terminated. But you saw a lot of messages continued flowing into the log viewer in the Katalon Studio GUI for a long period (a few minutes, probably) after the browser closed, so that you got a mis-perception that the browser closed before the Test Case finished.
Please have a look at the following topic of mine. There I reported a case that a Test Suite actually finished far earlier before the Log Viewer completes flushing the bulk of buffered logs.
I suppose, your Test Case emitted a lot of messages which were buffered somewhere inside Katalon Studio; and Katalon Studio took a long period to flush the buffered strings into the LogViewer display after the Test Case had already terminalted.
You should read the log carefully and find out when/how the browser was closed. I guess that you haven’t studied the log carefully because the log contained so many useless messages that you were discouraged to read it.
Your Test Case has a loop of for(i=1;i<577;i++) {...}. It is a poor idea to perform a big loop in a Test Case, as Katalon Studio recklessly emits START/END messages for every single statements in a Test Case. The messages could pile a huge amount.
You should change your code so that it emits less messages. But how to change the code? — I don’t know. You disclosed no source code, no log messages. Therefore I can not advice you any more. Please disclose more information (the entire source code of your test case, the “Data” file, and the full log) if you want a better advice.
If you can change the source of Data class, you should be able to transplant the for (i=1;i<577;i++) {...} portion out of the test case into the Data class. Then your test case would get simpler and better. You would have a chance to change the test case so that it emits no bulky START/END messages.