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(‘\\\\’, ‘\\’))
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')
CustomKeywords.'utils.Utilidades.cargaFichero'('/Files/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
*/
@Keyword
def cargaFichero(String path,String object) {
try{
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")
}
}
}
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
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