Upload file using robot not working when using Chrome browser

Hi, I have encountered issue which when I wanted to upload file using chrome browser, it will pop up the open windows twice (in red box) but this issue is not happening when using firefox:

I have set this file path in my test data:
Column Name: DocumentPath
DocumentPath = C:\Users\Jess\Pictures\Saved Pictures\17394.jpg

And in the test case, I have added the following code:
CustomKeywords.‘com.javascript.handling.utilities.uploadFiles.uploadFile’(findTestObject(‘Patient Registration/Page_Emergency Visit Registration/btn_UploadDocument’),
DocumentPath.replaceAll(‘\\\\’, ‘\\’))

Below is what I have added in custom keywords:

Appreciate if anyone can help on this.

Hi, I’m not sure if this might be of any help, but I’ll share a different way of uploading a file by using ‘uploadFileWithDragAndDrop’.

 ------------------------ how to call CustomKeywords to upload file --------------------------

// Start upload file (file locate in folder 'Files' which is located in our project, the file to be uploaded is 'upload_pdf.pdf')
	'NotificacionesOR/Fase 1 y 2/boton_SUBIR ARCHIVO PDF') // this is the object where to upload file located in OR

------------------------------------------------- CustomKeywords to upload file by using  uploadFileWithDragAndDrop----------------------------
package utils
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.util.KeywordUtil
import com.kms.katalon.core.webui.exception.WebElementNotFoundException
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

import groovy.sql.Sql

class Utilidades {

	 * Upload file
	 * @param path ,path to file 
	 * @param object Katalon test object en Object Repository
	def cargaFichero(String path,String object) {
			KeywordUtil.logInfo("Uploading file")
			def	filePath = RunConfiguration.getProjectDir() + path
			WebUI.uploadFileWithDragAndDrop(findTestObject(object), filePath)
		}catch (WebElementNotFoundException e) {
			KeywordUtil.markFailed("Element not found")
		} catch (Exception e) {
			KeywordUtil.markFailed("Fail to click on element")

This works for me:

i have tried on this solution…but still not working in chrome browser, i added robot.delay between each press & release line in the code still the same

Are you picking the right object? It should be the field where you would type the filename. Your object seems to be btn?

CustomKeywords.‘tools.uploadFiles.uploadFile’(findTestObject(‘Input_field’), ‘C:\TestFiles\file001.jpg’)

Yes. it is pointing to the correct object. The issue is only happening in chrome which at the first time it shows the “Open” windows then enter the image path in the "File Name’ field there. After that it close the windows & pop up again without doin anything

Maybe increase wait times?
Max out to 10000 and Back off?

Robot robot = new Robot();
robot.delay(10000); //ten sec

still having the same issue :sweat_smile:

One more idea…
Maybe try using CSS.

Update: How-to use ‘sendKeys’ or 'File Upload' to upload files when the //input[@type,'file'] is hidden