How to Interact with File Upload Window


I\'m trying to automate file attachment / file upload to gmail. While the rest of automation is working, the popup window to select file that needed to upload is not working. I already went through some file upload guide but still cannot get it done.

Please see this screenshot: 1 — ImgBB

It works until step number 2. But then failed to select the file on step number 3.

Kindly please help

We can’t access your link. Can you upload your screenshot again to other page such as

I use the Set text |imput_filename | path\nameoffile.doc
The script looks like this
WebUI.setText(findTestObject(‘Page_Edit Business Card/input_FileName’), ‘U:\Resume of a Tester.doc’)
I had an issue finding the input object as Katalon didn’t record it directly, I end up using Spyweb to find it.

WebUI.setText(findTestObject(‘Page_Edit Business Card/input_FileName’), ‘U:\Resume of a Tester.doc’)

you can try by specifying the xpath as “//input[@type=‘file’]” in the “input_FileName” test object.
or alternatively create a custom object and specify the xpath as “//input[@type=‘file’]”

1 Like

You can try also AutoIT scripting:

Hello ,
You can follow these steps for this situation.
1-You must create a new custom keyword. You can access the link below for new add Custom Keyword .

2-You must add the following snippet in Keyword.
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable

public class testclass {

def uploadFile (TestObject to, String filePath) {
	StringSelection ss = new StringSelection(filePath);
	Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
	Robot robot = new Robot();


3-Finally, you should call keyword u in the corresponding step.
After the keyword is included in the project, the relevant test case step in the script field should be as follows.
CustomKeywords.‘test.testclass.uploadFile’(findTestObject(‘Test_uploadfile_field’), 'C:\Users\\Desktop\test data)

Hopefully it is helpful.

It works for me. However, if I used custom keyword again in the same test case, it’s not working in the 2nd object.

Here’s my script