"Interactive" Test with Katalon

Does Katalon allow

  • to stop a test case
  • provide a textual output to the user (i.e. the one starting the test)
  • ask the user for input
  • continue with the test based on that input ?

I am not sure what keywords I should use for searching for this use case

Can be either in console mode or in Interactive mode ,

Your help is greatly appreciated

Hi Erik

If I understand what you’re asking for, short answer, no.

The longer answer is, perhaps, kind of, maybe.

I think what you’re asking for used to be referred to as Scripted Mode (it’s unfortunate that the noun/verb “script” is so overloaded and (mis)used these days but I’m going to try to make it clear, here, right at the outset).

A long time ago (couple decades or more), there was the idea that a “tester” needed to be told what to do by a “script”. (S)he read from a “script”. The script could interact with the tester (user) and interact with the AUT. It appeared alongside the AUT and the tester followed instructions in the script and responded to prompts which drove the AUT. I think there was a way to do this in Se1 (before the webdriver/Se2 stuff came along). But anyway…

It was a dumb way to test – for reasons too numerous to mention, it was just awful. I think (for me) the worst was, it never really told you anything. That is, it was hard to “measure” and gauge results and generate useful metrics/statistics. I know this because I wrote one. It worked GREAT! But the outcomes? Essentially useless.

So, assuming that’s the kind of thing you’re asking about, here’s the answer to, can Katalon do this?

No, not right out of the box. However, Katalon allows you to inject JavaScript into the page. If you can inject JavaScript, you can inject JS that creates a UI. So you could write your own.

But remember, just because you can, doesn’t mean you should.

2 Likes

Thanks for the answer.
Maybe I should be more precise here …
The output of the API would need to be copy/pasted into another program (running on the PC) by the user (or can Katalon control external programs maybe ??) and the response of the program needs to be sent to a next call.

You can execute external command (shell command, .sh script, windows *.bat, perl, python, ruby etc) from Katalon test case. See this and find references:

Katalon’s test case is a Groovy script. In Groovy you can execute external commands. Have a look at the following article, type the sample code into a test case in Katalon Studio, and “Run” it. It should work.

Let me show you an example. Please make a test case with any name in Katalon Studio, paste the following code, and RUN it. This script will execute Windows’ ipconfig command, read the stdout and stderr from the process and print it.

import java.nio.charset.Charset

String[] CMD = { "cmd", "/c", "ipconfig.exe"}

String WINCHARSET = "MS932"    
// Charset used for the output of the command, depends on your Windows PC environment, 
// see https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html

// Run the Windows command
Process process = Runtime.getRuntime().exec(CMD)

// Get input streams
BufferedReader stdInput = 
    new BufferedReader(
        new InputStreamReader(
            process.getInputStream(),
            Charset.forName(WINCHARSET)
        )
    )
BufferedReader stdError = 
    new BufferedReader(
        new InputStreamReader(
            process.getErrorStream(),
            Charset.forName(WINCHARSET)
        )
    )

// Read command standard output
String s
StringBuilder sb = new StringBuilder()
sb.append("Standard output: \n")
while ((s = stdInput.readLine()) != null) {
	sb.append(s + "\n")
}

// Read command errors
sb.append("Standard error: \n")
while ((s = stdError.readLine()) != null) {
	sb.append(s+ "\n")
}

System.out.println(sb.toString())

I cheated. The origianl was https://stackoverflow.com/questions/7112259/how-to-execute-windows-commands-using-java-change-network-settings

2 Likes

Thanks again for your help !

Thank you @kazurayam
It’s greatly helpful for me.

Appreciate so much.

And I also find another way, from the link you supply

def command = "your command"
Process process = command.execute()
def out = new StringBuffer()
def err = new StringBuffer()
process.consumeProcessOutput( out, err )
process.waitFor()
if( out.size() > 0 ) println out
if( err.size() > 0 ) println err

Cheers
Newman

1 Like