Katalon’s Response Object is designed to process JSON/XML text only. It is not designed to process binary responses. See https://github.com/katalon-studio/katalon-studio-testing-framework/blob/master/Include/scripts/groovy/com/kms/katalon/core/testobject/ResponseObject.java getResponseBodyContent()
If you want to download binary data from URL in a Test Case of Katalon Studio, you should write a bit of Groovy script. Let me show you an example. Please make a test case with any name, copy & paste the following snippet, and run it. You will get an image file at <projectDir>/tmp/avator.png
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import com.kms.katalon.core.configuration.RunConfiguration
Path projectDir = Paths.get(RunConfiguration.getProjectDir())
Path tmpDir = projectDir.resolve('tmp')
Files.createDirectories(tmpDir)
Path output = tmpDir.resolve("avator.png")
URL url = new URL("https://forum.katalon.com/user_avatar/forum.katalon.com/kazurayam/45/333_1.png")
URLConnection connection = url.openConnection()
InputStream is = connection.getInputStream()
OutputStream os = new FileOutputStream(output.toFile())
byte[] buffer = new byte[4096]
int n
while ((n = is.read(buffer)) != -1) {
os.write(buffer, 0, n)
}
os.close
Comments
0 comments
Please sign in to leave a comment.