Multiple Upload functionality


#1

How to upload multiple files?


#2

#3

I want to upload multiple files (Docx / PDF) , I have used UploadFile functionality . Following is the code -

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import groovy.io.FileType

def list = []

def dir = new File(“C:\SampleFolder”)
dir.eachFileRecurse (FileType.FILES) { file ->
list << file
}

for (item in list) {
WebUI.uploadFile(findTestObject(‘SamplePage/btn_UploadFile’), item)
}

But this is not working. Getting Error as -

for (def item : list) FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.uploadFile() is applicable for argument types: (com.kms.katalon.core.testobject.TestObject, java.io.File)


I am able to upload single file using-

WebUI.uploadFile(findTestObject(‘SamplePage/btn_UploadFile’), filePathofthefiletoupload)


#4

WebUI.uploadFile() takes TestObject and String (path to a file), not File itself. You must get a path from File object and pass it to the keyword.