Upload File with Choose File and Upload buttons on the UI

Hi Team,
Please can you help me on uploading the files, from a web page.
There is ‘Choose File’ and ‘Upload’ buttons on the page.
The file explorer opens only after i sent on the Choose File button, how do i automate the upload doc step while i am on the web page where i also need to perform other actions like selecting values from other fields.
For example in the below snippet i have a field where i have to select the document type, before i can choose a file to upload and then click on the Upload button to Upload, Finally have to click on the ‘Save’ button on the page.

Hi mitali
This might help you.

Regards
Kavya

hello,

I tried the upload step as suggested, however i am getting this error-

2019-01-27 18:48:38.896 e[1;31mERRORe[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[31m❌ uploadFile(findTestObject(“Submit Application/Page_Online Application for Intelle/9_Application Supporting Documents/div_Choose File”), “C:\Users\mitali.p.shah\Downloads\Test.docx”) FAILED.e[0;39m
e[31mReason:e[0;39m
e[31mcom.kms.katalon.core.exception.StepFailedException: Unable to upload file ‘C:\Users\mitali.p.shah\Downloads\Test.docx’ to object ‘Object Repository/Submit Application/Page_Online Application for Intelle/9_Application Supporting Documents/div_Choose File’ (Root cause: org.openqa.selenium.WebDriverException: unknown error: cannot focus element

This is my code-

Thread.sleep(5000)

WebUI.uploadFile(findTestObject(‘Submit Application/Page_Online Application for Intelle/9_Application Supporting Documents/div_Choose File’),
‘C:\Users\mitali.p.shah\Downloads\Test.docx’)

Thread.sleep(2000)

WebUI.click(findTestObject(‘Submit Application/Page_Online Application for Intelle/9_Application Supporting Documents/div_Upload’))

Any help to resolve this error is much appreciated.

Hello @mitali.p.shah, did you manage to solve the issue? ? I have the same problem :confused:

Give this a try…