Upload File Step Fail on Test Case While Running Katalon on Docker

Hi, I’ve test step to upload file. I used function upload like this :

static String path = RunConfiguration.getProjectDir() + '/Data Files/'
public static uploadFile(TestObject object, String file){
	path = path.replace('/', '\\');
	WebUI.uploadFile(object, path+file);

And I stored my file on Data Files folder. When I running on my local machine (Windows), nothing wrong happens. But, when I running on Docker, The error said that cannot find my file :

org.openqa.selenium.InvalidArgumentException: invalid argument: File not found : \tmp\katalon_execute\project\Data Files\expense.jpg

Can someone explain to me how to handle it? Thanks!

@ThanhTo could u help me, sir?

Im facing the same problem. I know the failure is something to do with path mounting. basically, the file doesnt exist in that path. try copying the file into a path in slave and try, and use that path to upload the file

Did you use same function to search file to upload?


Your code works on Windows only. It would never work on Linux in a docker container. You should avoid hard-coding platform-specific file path seperators: \ and /

Platform independent version:

import java.nio.file.Path
import java.nio.file.Paths
import com.kms.katalon.core.configuration.RunConfiguration
import ... as WebUI

static void uploadFile(TestObject object, String fileName) {
    Path dataFilesDir = Paths.get(RunConfiguration.getProject()).resolve('Data Files')
    Path fileToUpload = dataFilesDir.resolve(fileName)
    WebUI.uploadFile(object, fileToUpload.toString());
1 Like

I’ve been changed my code, forget to post solution to this thread, hehe. Thank you for your advice, btw

path = RunConfiguration.getProjectDir().concat('/Data Files/')

    	public static void uploadFile(TestObject to, String file) {
    		if(System.getProperty('os.name').toString().contains('Windows')) {
    			path = path.replace('/', '\\');
    		WebUI.uploadFile(to, path+file);