Is there are way to use file upload keyword on multiple places even the test objects are different for each place?

I have a file that I want to upload on 10 multiple places on a website and the test objects are different for each place. I want to create a keyword that I can use to upload the same file to all places. is there a way to do it using katalon studio?

Added Detail…
I have to upload one file in different places on the web using katalon

I am using:

‘Upload test-photo.png to input_browse’

WebUI.uploadFile(findTestObject('input_browse'), 'D:\\test-photo.png'

I have to upload the same file on below places

‘Upload test-photo.png to Object Repository/TKM/Page_/upload_AB_log’

WebUI.uploadFile(findTestObject('Object Repository/TKM/Page_/upload_AB_log'), 'D:\\test-photo.png'

‘Upload test-photo.png to Object Repository/TKM/Page_/Upload_BC_logo’

WebUI.uploadFile(findTestObject('Object Repository/TKM/Page_/Upload_BC_logo'), 'D:\\test-photo.png'

‘Upload test-photo.png to Object Repository/TKM/Page_/upload_CD_log’

WebUI.uploadFile(findTestObject('Object Repository/TKM/Page_/upload_CD_log'), 'D:\\test-photo.png'

'Upload test-photo.png to ‘Object Repository/TKM/Page_/upload_EF_logo’

WebUI.uploadFile(findTestObject('Object Repository/TKM/Page_/upload_EF_logo'), 'D:\\test-photo.png' 

The path/file to upload is the same but needs to upload in different places/input.

I am trying to create the keyword but due to the change of object/input, it’s not working for all.

Is there a way to create the keyword that will work for all uploads in katalon studio?

Of course that’s possible… but without a lot more information, I’d be surprised if anyone can help you.

Could you please help now ??

Your code looks complete. You have 5 <input> elements and 1 PNG file. So you wrote 5 lines of WebUI.uploadFile() call. If it runs OK, it’s good enough, isn’t it? I think you do not need to create any custom keyword.

I suppose you want to learn how to write a Keyword class, tried, and encountered a difficulty.

OK, then. Please show the source code of your keyword and your test case script that calls the keyword. Describe what you expected to see when you ran it, and what you actually saw in the log.

something like:

myUpload(TestObject to, String filePath){
  WebUI.uploadFile(to, filePath) 

and then in TC:


please read more about custom keywords in official documentation:

however in my opinion this is highly ineffective - you are making just wrapper to existing method … it will make sense if you will add more custom operations on that TO in your keyword.
one line keywords make no sense